Skip to content

Commit bfa4b14

Browse files
vedant-asatiSamWilsn
authored andcommitted
improve readability of calculations
1 parent bcee9d9 commit bfa4b14

File tree

14 files changed

+42
-70
lines changed

14 files changed

+42
-70
lines changed

src/ethereum/arrow_glacier/vm/instructions/system.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,9 @@ def call(evm: Evm) -> None:
353353

354354
code_address = to
355355

356-
create_gas_cost = (
357-
Uint(0)
358-
if is_account_alive(evm.message.block_env.state, to) or value == 0
359-
else GAS_NEW_ACCOUNT
360-
)
356+
create_gas_cost = GAS_NEW_ACCOUNT
357+
if value == 0 or is_account_alive(evm.message.block_env.state, to):
358+
create_gas_cost = Uint(0)
361359
transfer_gas_cost = Uint(0) if value == 0 else GAS_CALL_VALUE
362360
message_call_gas = calculate_message_call_gas(
363361
value,

src/ethereum/berlin/vm/instructions/system.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,9 @@ def call(evm: Evm) -> None:
354354

355355
code_address = to
356356

357-
create_gas_cost = (
358-
Uint(0)
359-
if is_account_alive(evm.message.block_env.state, to) or value == 0
360-
else GAS_NEW_ACCOUNT
361-
)
357+
create_gas_cost = GAS_NEW_ACCOUNT
358+
if value == 0 or is_account_alive(evm.message.block_env.state, to):
359+
create_gas_cost = Uint(0)
362360
transfer_gas_cost = Uint(0) if value == 0 else GAS_CALL_VALUE
363361
message_call_gas = calculate_message_call_gas(
364362
value,

src/ethereum/byzantium/vm/instructions/system.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,9 @@ def call(evm: Evm) -> None:
274274

275275
code_address = to
276276

277-
create_gas_cost = (
278-
Uint(0)
279-
if is_account_alive(evm.message.block_env.state, to) or value == 0
280-
else GAS_NEW_ACCOUNT
281-
)
277+
create_gas_cost = GAS_NEW_ACCOUNT
278+
if value == 0 or is_account_alive(evm.message.block_env.state, to):
279+
create_gas_cost = Uint(0)
282280
transfer_gas_cost = Uint(0) if value == 0 else GAS_CALL_VALUE
283281
message_call_gas = calculate_message_call_gas(
284282
value,

src/ethereum/cancun/vm/instructions/system.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,9 @@ def call(evm: Evm) -> None:
373373

374374
code_address = to
375375

376-
create_gas_cost = (
377-
Uint(0)
378-
if is_account_alive(evm.message.block_env.state, to) or value == 0
379-
else GAS_NEW_ACCOUNT
380-
)
376+
create_gas_cost = GAS_NEW_ACCOUNT
377+
if value == 0 or is_account_alive(evm.message.block_env.state, to):
378+
create_gas_cost = Uint(0)
381379
transfer_gas_cost = Uint(0) if value == 0 else GAS_CALL_VALUE
382380
message_call_gas = calculate_message_call_gas(
383381
value,

src/ethereum/constantinople/vm/instructions/system.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,9 @@ def call(evm: Evm) -> None:
344344

345345
code_address = to
346346

347-
create_gas_cost = (
348-
Uint(0)
349-
if is_account_alive(evm.message.block_env.state, to) or value == 0
350-
else GAS_NEW_ACCOUNT
351-
)
347+
create_gas_cost = GAS_NEW_ACCOUNT
348+
if value == 0 or is_account_alive(evm.message.block_env.state, to):
349+
create_gas_cost = Uint(0)
352350
transfer_gas_cost = Uint(0) if value == 0 else GAS_CALL_VALUE
353351
message_call_gas = calculate_message_call_gas(
354352
value,

src/ethereum/gray_glacier/vm/instructions/system.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,9 @@ def call(evm: Evm) -> None:
353353

354354
code_address = to
355355

356-
create_gas_cost = (
357-
Uint(0)
358-
if is_account_alive(evm.message.block_env.state, to) or value == 0
359-
else GAS_NEW_ACCOUNT
360-
)
356+
create_gas_cost = GAS_NEW_ACCOUNT
357+
if value == 0 or is_account_alive(evm.message.block_env.state, to):
358+
create_gas_cost = Uint(0)
361359
transfer_gas_cost = Uint(0) if value == 0 else GAS_CALL_VALUE
362360
message_call_gas = calculate_message_call_gas(
363361
value,

src/ethereum/istanbul/vm/instructions/system.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,9 @@ def call(evm: Evm) -> None:
344344

345345
code_address = to
346346

347-
create_gas_cost = (
348-
Uint(0)
349-
if is_account_alive(evm.message.block_env.state, to) or value == 0
350-
else GAS_NEW_ACCOUNT
351-
)
347+
create_gas_cost = GAS_NEW_ACCOUNT
348+
if value == 0 or is_account_alive(evm.message.block_env.state, to):
349+
create_gas_cost = Uint(0)
352350
transfer_gas_cost = Uint(0) if value == 0 else GAS_CALL_VALUE
353351
message_call_gas = calculate_message_call_gas(
354352
value,

src/ethereum/london/vm/instructions/system.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,9 @@ def call(evm: Evm) -> None:
353353

354354
code_address = to
355355

356-
create_gas_cost = (
357-
Uint(0)
358-
if is_account_alive(evm.message.block_env.state, to) or value == 0
359-
else GAS_NEW_ACCOUNT
360-
)
356+
create_gas_cost = GAS_NEW_ACCOUNT
357+
if value == 0 or is_account_alive(evm.message.block_env.state, to):
358+
create_gas_cost = Uint(0)
361359
transfer_gas_cost = Uint(0) if value == 0 else GAS_CALL_VALUE
362360
message_call_gas = calculate_message_call_gas(
363361
value,

src/ethereum/muir_glacier/vm/instructions/system.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,9 @@ def call(evm: Evm) -> None:
344344

345345
code_address = to
346346

347-
create_gas_cost = (
348-
Uint(0)
349-
if is_account_alive(evm.message.block_env.state, to) or value == 0
350-
else GAS_NEW_ACCOUNT
351-
)
347+
create_gas_cost = GAS_NEW_ACCOUNT
348+
if value == 0 or is_account_alive(evm.message.block_env.state, to):
349+
create_gas_cost = Uint(0)
352350
transfer_gas_cost = Uint(0) if value == 0 else GAS_CALL_VALUE
353351
message_call_gas = calculate_message_call_gas(
354352
value,

src/ethereum/osaka/vm/instructions/system.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,9 @@ def call(evm: Evm) -> None:
394394
) = access_delegation(evm, code_address)
395395
access_gas_cost += delegated_access_gas_cost
396396

397-
create_gas_cost = (
398-
Uint(0)
399-
if is_account_alive(evm.message.block_env.state, to) or value == 0
400-
else GAS_NEW_ACCOUNT
401-
)
397+
create_gas_cost = GAS_NEW_ACCOUNT
398+
if value == 0 or is_account_alive(evm.message.block_env.state, to):
399+
create_gas_cost = Uint(0)
402400
transfer_gas_cost = Uint(0) if value == 0 else GAS_CALL_VALUE
403401
message_call_gas = calculate_message_call_gas(
404402
value,

0 commit comments

Comments
 (0)