Skip to content

Commit 77763f2

Browse files
gurukamathSamWilsn
authored andcommitted
change gas variable names
1 parent 11daa56 commit 77763f2

File tree

17 files changed

+155
-121
lines changed

17 files changed

+155
-121
lines changed

src/ethereum/arrow_glacier/fork.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -753,15 +753,17 @@ def process_transaction(
753753

754754
tx_output = process_message_call(message)
755755

756-
gas_used = tx.gas - tx_output.gas_left
757-
gas_refund = min(gas_used // Uint(5), Uint(tx_output.refund_counter))
758-
tx_gas_used = gas_used - gas_refund
759-
tx_output.gas_left = tx.gas - tx_gas_used
760-
gas_refund_amount = tx_output.gas_left * effective_gas_price
756+
tx_gas_used_before_refund = tx.gas - tx_output.gas_left
757+
tx_gas_refund = min(
758+
tx_gas_used_before_refund // Uint(5), Uint(tx_output.refund_counter)
759+
)
760+
tx_gas_used_after_refund = tx_gas_used_before_refund - tx_gas_refund
761+
tx_gas_left = tx.gas - tx_gas_used_after_refund
762+
gas_refund_amount = tx_gas_left * effective_gas_price
761763

762764
# For non-1559 transactions effective_gas_price == tx.gas_price
763765
priority_fee_per_gas = effective_gas_price - block_env.base_fee_per_gas
764-
transaction_fee = tx_gas_used * priority_fee_per_gas
766+
transaction_fee = tx_gas_used_after_refund * priority_fee_per_gas
765767

766768
# refund gas
767769
sender_balance_after_refund = get_account(
@@ -787,7 +789,7 @@ def process_transaction(
787789

788790
destroy_touched_empty_accounts(block_env.state, tx_output.touched_accounts)
789791

790-
block_output.block_gas_used += tx_gas_used
792+
block_output.block_gas_used += tx_gas_used_after_refund
791793

792794
receipt = make_receipt(
793795
tx, tx_output.error, block_output.block_gas_used, tx_output.logs

src/ethereum/berlin/fork.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -654,13 +654,15 @@ def process_transaction(
654654

655655
tx_output = process_message_call(message)
656656

657-
gas_used = tx.gas - tx_output.gas_left
658-
gas_refund = min(gas_used // Uint(2), Uint(tx_output.refund_counter))
659-
tx_gas_used = gas_used - gas_refund
660-
tx_output.gas_left = tx.gas - tx_gas_used
661-
gas_refund_amount = tx_output.gas_left * tx.gas_price
657+
tx_gas_used_before_refund = tx.gas - tx_output.gas_left
658+
tx_gas_refund = min(
659+
tx_gas_used_before_refund // Uint(2), Uint(tx_output.refund_counter)
660+
)
661+
tx_gas_used_after_refund = tx_gas_used_before_refund - tx_gas_refund
662+
tx_gas_left = tx.gas - tx_gas_used_after_refund
663+
gas_refund_amount = tx_gas_left * tx.gas_price
662664

663-
transaction_fee = tx_gas_used * tx.gas_price
665+
transaction_fee = tx_gas_used_after_refund * tx.gas_price
664666

665667
# refund gas
666668
sender_balance_after_refund = get_account(
@@ -686,7 +688,7 @@ def process_transaction(
686688

687689
destroy_touched_empty_accounts(block_env.state, tx_output.touched_accounts)
688690

689-
block_output.block_gas_used += tx_gas_used
691+
block_output.block_gas_used += tx_gas_used_after_refund
690692

691693
receipt = make_receipt(
692694
tx, tx_output.error, block_output.block_gas_used, tx_output.logs

src/ethereum/byzantium/fork.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -631,13 +631,15 @@ def process_transaction(
631631

632632
tx_output = process_message_call(message)
633633

634-
gas_used = tx.gas - tx_output.gas_left
635-
gas_refund = min(gas_used // Uint(2), Uint(tx_output.refund_counter))
636-
tx_gas_used = gas_used - gas_refund
637-
tx_output.gas_left = tx.gas - tx_gas_used
638-
gas_refund_amount = tx_output.gas_left * tx.gas_price
634+
tx_gas_used_before_refund = tx.gas - tx_output.gas_left
635+
tx_gas_refund = min(
636+
tx_gas_used_before_refund // Uint(2), Uint(tx_output.refund_counter)
637+
)
638+
tx_gas_used_after_refund = tx_gas_used_before_refund - tx_gas_refund
639+
tx_gas_left = tx.gas - tx_gas_used_after_refund
640+
gas_refund_amount = tx_gas_left * tx.gas_price
639641

640-
transaction_fee = tx_gas_used * tx.gas_price
642+
transaction_fee = tx_gas_used_after_refund * tx.gas_price
641643

642644
# refund gas
643645
sender_balance_after_refund = get_account(
@@ -663,7 +665,7 @@ def process_transaction(
663665

664666
destroy_touched_empty_accounts(block_env.state, tx_output.touched_accounts)
665667

666-
block_output.block_gas_used += tx_gas_used
668+
block_output.block_gas_used += tx_gas_used_after_refund
667669

668670
receipt = make_receipt(
669671
tx_output.error, block_output.block_gas_used, tx_output.logs

src/ethereum/cancun/fork.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -680,15 +680,17 @@ def process_transaction(
680680

681681
tx_output = process_message_call(message)
682682

683-
gas_used = tx.gas - tx_output.gas_left
684-
gas_refund = min(gas_used // Uint(5), Uint(tx_output.refund_counter))
685-
tx_gas_used = gas_used - gas_refund
686-
tx_output.gas_left = tx.gas - tx_gas_used
687-
gas_refund_amount = tx_output.gas_left * effective_gas_price
683+
tx_gas_used_before_refund = tx.gas - tx_output.gas_left
684+
tx_gas_refund = min(
685+
tx_gas_used_before_refund // Uint(5), Uint(tx_output.refund_counter)
686+
)
687+
tx_gas_used_after_refund = tx_gas_used_before_refund - tx_gas_refund
688+
tx_gas_left = tx.gas - tx_gas_used_after_refund
689+
gas_refund_amount = tx_gas_left * effective_gas_price
688690

689691
# For non-1559 transactions effective_gas_price == tx.gas_price
690692
priority_fee_per_gas = effective_gas_price - block_env.base_fee_per_gas
691-
transaction_fee = tx_gas_used * priority_fee_per_gas
693+
transaction_fee = tx_gas_used_after_refund * priority_fee_per_gas
692694

693695
# refund gas
694696
sender_balance_after_refund = get_account(
@@ -712,7 +714,7 @@ def process_transaction(
712714
for address in tx_output.accounts_to_delete:
713715
destroy_account(block_env.state, address)
714716

715-
block_output.block_gas_used += tx_gas_used
717+
block_output.block_gas_used += tx_gas_used_after_refund
716718
block_output.blob_gas_used += tx_blob_gas_used
717719

718720
receipt = make_receipt(

src/ethereum/constantinople/fork.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -631,13 +631,15 @@ def process_transaction(
631631

632632
tx_output = process_message_call(message)
633633

634-
gas_used = tx.gas - tx_output.gas_left
635-
gas_refund = min(gas_used // Uint(2), Uint(tx_output.refund_counter))
636-
tx_gas_used = gas_used - gas_refund
637-
tx_output.gas_left = tx.gas - tx_gas_used
638-
gas_refund_amount = tx_output.gas_left * tx.gas_price
634+
tx_gas_used_before_refund = tx.gas - tx_output.gas_left
635+
tx_gas_refund = min(
636+
tx_gas_used_before_refund // Uint(2), Uint(tx_output.refund_counter)
637+
)
638+
tx_gas_used_after_refund = tx_gas_used_before_refund - tx_gas_refund
639+
tx_gas_left = tx.gas - tx_gas_used_after_refund
640+
gas_refund_amount = tx_gas_left * tx.gas_price
639641

640-
transaction_fee = tx_gas_used * tx.gas_price
642+
transaction_fee = tx_gas_used_after_refund * tx.gas_price
641643

642644
# refund gas
643645
sender_balance_after_refund = get_account(
@@ -663,7 +665,7 @@ def process_transaction(
663665

664666
destroy_touched_empty_accounts(block_env.state, tx_output.touched_accounts)
665667

666-
block_output.block_gas_used += tx_gas_used
668+
block_output.block_gas_used += tx_gas_used_after_refund
667669

668670
receipt = make_receipt(
669671
tx_output.error, block_output.block_gas_used, tx_output.logs

src/ethereum/dao_fork/fork.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -640,13 +640,15 @@ def process_transaction(
640640

641641
tx_output = process_message_call(message)
642642

643-
gas_used = tx.gas - tx_output.gas_left
644-
gas_refund = min(gas_used // Uint(2), Uint(tx_output.refund_counter))
645-
tx_gas_used = gas_used - gas_refund
646-
tx_output.gas_left = tx.gas - tx_gas_used
647-
gas_refund_amount = tx_output.gas_left * tx.gas_price
643+
tx_gas_used_before_refund = tx.gas - tx_output.gas_left
644+
tx_gas_refund = min(
645+
tx_gas_used_before_refund // Uint(2), Uint(tx_output.refund_counter)
646+
)
647+
tx_gas_used_after_refund = tx_gas_used_before_refund - tx_gas_refund
648+
tx_gas_left = tx.gas - tx_gas_used_after_refund
649+
gas_refund_amount = tx_gas_left * tx.gas_price
648650

649-
transaction_fee = tx_gas_used * tx.gas_price
651+
transaction_fee = tx_gas_used_after_refund * tx.gas_price
650652

651653
# refund gas
652654
sender_balance_after_refund = get_account(
@@ -665,7 +667,7 @@ def process_transaction(
665667
for address in tx_output.accounts_to_delete:
666668
destroy_account(block_env.state, address)
667669

668-
block_output.block_gas_used += tx_gas_used
670+
block_output.block_gas_used += tx_gas_used_after_refund
669671

670672
receipt = make_receipt(
671673
state_root(block_env.state),

src/ethereum/frontier/fork.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -623,13 +623,15 @@ def process_transaction(
623623

624624
tx_output = process_message_call(message)
625625

626-
gas_used = tx.gas - tx_output.gas_left
627-
gas_refund = min(gas_used // Uint(2), Uint(tx_output.refund_counter))
628-
tx_gas_used = gas_used - gas_refund
629-
tx_output.gas_left = tx.gas - tx_gas_used
630-
gas_refund_amount = tx_output.gas_left * tx.gas_price
626+
tx_gas_used_before_refund = tx.gas - tx_output.gas_left
627+
tx_gas_refund = min(
628+
tx_gas_used_before_refund // Uint(2), Uint(tx_output.refund_counter)
629+
)
630+
tx_gas_used_after_refund = tx_gas_used_before_refund - tx_gas_refund
631+
tx_gas_left = tx.gas - tx_gas_used_after_refund
632+
gas_refund_amount = tx_gas_left * tx.gas_price
631633

632-
transaction_fee = tx_gas_used * tx.gas_price
634+
transaction_fee = tx_gas_used_after_refund * tx.gas_price
633635

634636
# refund gas
635637
sender_balance_after_refund = get_account(
@@ -648,7 +650,7 @@ def process_transaction(
648650
for address in tx_output.accounts_to_delete:
649651
destroy_account(block_env.state, address)
650652

651-
block_output.block_gas_used += tx_gas_used
653+
block_output.block_gas_used += tx_gas_used_after_refund
652654

653655
receipt = make_receipt(
654656
state_root(block_env.state),

src/ethereum/gray_glacier/fork.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -753,15 +753,17 @@ def process_transaction(
753753

754754
tx_output = process_message_call(message)
755755

756-
gas_used = tx.gas - tx_output.gas_left
757-
gas_refund = min(gas_used // Uint(5), Uint(tx_output.refund_counter))
758-
tx_gas_used = gas_used - gas_refund
759-
tx_output.gas_left = tx.gas - tx_gas_used
760-
gas_refund_amount = tx_output.gas_left * effective_gas_price
756+
tx_gas_used_before_refund = tx.gas - tx_output.gas_left
757+
tx_gas_refund = min(
758+
tx_gas_used_before_refund // Uint(5), Uint(tx_output.refund_counter)
759+
)
760+
tx_gas_used_after_refund = tx_gas_used_before_refund - tx_gas_refund
761+
tx_gas_left = tx.gas - tx_gas_used_after_refund
762+
gas_refund_amount = tx_gas_left * effective_gas_price
761763

762764
# For non-1559 transactions effective_gas_price == tx.gas_price
763765
priority_fee_per_gas = effective_gas_price - block_env.base_fee_per_gas
764-
transaction_fee = tx_gas_used * priority_fee_per_gas
766+
transaction_fee = tx_gas_used_after_refund * priority_fee_per_gas
765767

766768
# refund gas
767769
sender_balance_after_refund = get_account(
@@ -787,7 +789,7 @@ def process_transaction(
787789

788790
destroy_touched_empty_accounts(block_env.state, tx_output.touched_accounts)
789791

790-
block_output.block_gas_used += tx_gas_used
792+
block_output.block_gas_used += tx_gas_used_after_refund
791793

792794
receipt = make_receipt(
793795
tx, tx_output.error, block_output.block_gas_used, tx_output.logs

src/ethereum/homestead/fork.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -623,13 +623,15 @@ def process_transaction(
623623

624624
tx_output = process_message_call(message)
625625

626-
gas_used = tx.gas - tx_output.gas_left
627-
gas_refund = min(gas_used // Uint(2), Uint(tx_output.refund_counter))
628-
tx_gas_used = gas_used - gas_refund
629-
tx_output.gas_left = tx.gas - tx_gas_used
630-
gas_refund_amount = tx_output.gas_left * tx.gas_price
626+
tx_gas_used_before_refund = tx.gas - tx_output.gas_left
627+
tx_gas_refund = min(
628+
tx_gas_used_before_refund // Uint(2), Uint(tx_output.refund_counter)
629+
)
630+
tx_gas_used_after_refund = tx_gas_used_before_refund - tx_gas_refund
631+
tx_gas_left = tx.gas - tx_gas_used_after_refund
632+
gas_refund_amount = tx_gas_left * tx.gas_price
631633

632-
transaction_fee = tx_gas_used * tx.gas_price
634+
transaction_fee = tx_gas_used_after_refund * tx.gas_price
633635

634636
# refund gas
635637
sender_balance_after_refund = get_account(
@@ -648,7 +650,7 @@ def process_transaction(
648650
for address in tx_output.accounts_to_delete:
649651
destroy_account(block_env.state, address)
650652

651-
block_output.block_gas_used += tx_gas_used
653+
block_output.block_gas_used += tx_gas_used_after_refund
652654

653655
receipt = make_receipt(
654656
state_root(block_env.state),

src/ethereum/istanbul/fork.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -631,13 +631,15 @@ def process_transaction(
631631

632632
tx_output = process_message_call(message)
633633

634-
gas_used = tx.gas - tx_output.gas_left
635-
gas_refund = min(gas_used // Uint(2), Uint(tx_output.refund_counter))
636-
tx_gas_used = gas_used - gas_refund
637-
tx_output.gas_left = tx.gas - tx_gas_used
638-
gas_refund_amount = tx_output.gas_left * tx.gas_price
634+
tx_gas_used_before_refund = tx.gas - tx_output.gas_left
635+
tx_gas_refund = min(
636+
tx_gas_used_before_refund // Uint(2), Uint(tx_output.refund_counter)
637+
)
638+
tx_gas_used_after_refund = tx_gas_used_before_refund - tx_gas_refund
639+
tx_gas_left = tx.gas - tx_gas_used_after_refund
640+
gas_refund_amount = tx_gas_left * tx.gas_price
639641

640-
transaction_fee = tx_gas_used * tx.gas_price
642+
transaction_fee = tx_gas_used_after_refund * tx.gas_price
641643

642644
# refund gas
643645
sender_balance_after_refund = get_account(
@@ -663,7 +665,7 @@ def process_transaction(
663665

664666
destroy_touched_empty_accounts(block_env.state, tx_output.touched_accounts)
665667

666-
block_output.block_gas_used += tx_gas_used
668+
block_output.block_gas_used += tx_gas_used_after_refund
667669

668670
receipt = make_receipt(
669671
tx_output.error, block_output.block_gas_used, tx_output.logs

0 commit comments

Comments
 (0)