Skip to content

Commit

Permalink
Clean up conditionals in vm/instructions/system.py
Browse files Browse the repository at this point in the history
  • Loading branch information
SamWilsn committed May 7, 2024
1 parent c923da6 commit 0f116b5
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions src/ethereum/arrow_glacier/vm/instructions/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def generic_create(

create_message_gas = max_message_call_gas(Uint(evm.gas_left))
evm.gas_left -= create_message_gas
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext
evm.return_data = b""

Expand Down Expand Up @@ -351,7 +351,7 @@ def call(evm: Evm) -> None:
access_gas_cost + create_gas_cost + transfer_gas_cost,
)
charge_gas(evm, message_call_gas.cost + extend_memory.cost)
if not (not evm.message.is_static or value == U256(0)):
if evm.message.is_static and value != U256(0):
raise WriteInStaticContext
evm.memory += b"\x00" * extend_memory.expand_by
sender_balance = get_account(
Expand Down Expand Up @@ -480,7 +480,7 @@ def selfdestruct(evm: Evm) -> None:
gas_cost += GAS_SELF_DESTRUCT_NEW_ACCOUNT

charge_gas(evm, gas_cost)
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext

originator = evm.message.current_target
Expand Down
6 changes: 3 additions & 3 deletions src/ethereum/berlin/vm/instructions/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def generic_create(

create_message_gas = max_message_call_gas(Uint(evm.gas_left))
evm.gas_left -= create_message_gas
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext
evm.return_data = b""

Expand Down Expand Up @@ -352,7 +352,7 @@ def call(evm: Evm) -> None:
access_gas_cost + create_gas_cost + transfer_gas_cost,
)
charge_gas(evm, message_call_gas.cost + extend_memory.cost)
if not (not evm.message.is_static or value == U256(0)):
if evm.message.is_static and value != U256(0):
raise WriteInStaticContext
evm.memory += b"\x00" * extend_memory.expand_by
sender_balance = get_account(
Expand Down Expand Up @@ -492,7 +492,7 @@ def selfdestruct(evm: Evm) -> None:
evm.refund_counter += REFUND_SELF_DESTRUCT

charge_gas(evm, gas_cost)
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext

beneficiary_balance = get_account(evm.env.state, beneficiary).balance
Expand Down
6 changes: 3 additions & 3 deletions src/ethereum/byzantium/vm/instructions/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def create(evm: Evm) -> None:

create_message_gas = max_message_call_gas(Uint(evm.gas_left))
evm.gas_left -= create_message_gas
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext
evm.memory += b"\x00" * extend_memory.expand_by
evm.return_data = b""
Expand Down Expand Up @@ -271,7 +271,7 @@ def call(evm: Evm) -> None:
GAS_CALL + create_gas_cost + transfer_gas_cost,
)
charge_gas(evm, message_call_gas.cost + extend_memory.cost)
if not (not evm.message.is_static or value == U256(0)):
if evm.message.is_static and value != U256(0):
raise WriteInStaticContext
evm.memory += b"\x00" * extend_memory.expand_by
sender_balance = get_account(
Expand Down Expand Up @@ -400,7 +400,7 @@ def selfdestruct(evm: Evm) -> None:
evm.refund_counter += REFUND_SELF_DESTRUCT

charge_gas(evm, gas_cost)
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext

beneficiary_balance = get_account(evm.env.state, beneficiary).balance
Expand Down
8 changes: 4 additions & 4 deletions src/ethereum/cancun/vm/instructions/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ def generic_create(
call_data = memory_read_bytes(
evm.memory, memory_start_position, memory_size
)
if not (len(call_data) <= 2 * MAX_CODE_SIZE):
if len(call_data) > 2 * MAX_CODE_SIZE:
raise OutOfGasError

evm.accessed_addresses.add(contract_address)

create_message_gas = max_message_call_gas(Uint(evm.gas_left))
evm.gas_left -= create_message_gas
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext
evm.return_data = b""

Expand Down Expand Up @@ -375,7 +375,7 @@ def call(evm: Evm) -> None:
access_gas_cost + create_gas_cost + transfer_gas_cost,
)
charge_gas(evm, message_call_gas.cost + extend_memory.cost)
if not (not evm.message.is_static or value == U256(0)):
if evm.message.is_static and value != U256(0):
raise WriteInStaticContext
evm.memory += b"\x00" * extend_memory.expand_by
sender_balance = get_account(
Expand Down Expand Up @@ -504,7 +504,7 @@ def selfdestruct(evm: Evm) -> None:
gas_cost += GAS_SELF_DESTRUCT_NEW_ACCOUNT

charge_gas(evm, gas_cost)
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext

originator = evm.message.current_target
Expand Down
6 changes: 3 additions & 3 deletions src/ethereum/constantinople/vm/instructions/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def generic_create(

create_message_gas = max_message_call_gas(Uint(evm.gas_left))
evm.gas_left -= create_message_gas
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext
evm.return_data = b""

Expand Down Expand Up @@ -338,7 +338,7 @@ def call(evm: Evm) -> None:
GAS_CALL + create_gas_cost + transfer_gas_cost,
)
charge_gas(evm, message_call_gas.cost + extend_memory.cost)
if not (not evm.message.is_static or value == U256(0)):
if evm.message.is_static and value != U256(0):
raise WriteInStaticContext
evm.memory += b"\x00" * extend_memory.expand_by
sender_balance = get_account(
Expand Down Expand Up @@ -467,7 +467,7 @@ def selfdestruct(evm: Evm) -> None:
evm.refund_counter += REFUND_SELF_DESTRUCT

charge_gas(evm, gas_cost)
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext

beneficiary_balance = get_account(evm.env.state, beneficiary).balance
Expand Down
6 changes: 3 additions & 3 deletions src/ethereum/gray_glacier/vm/instructions/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def generic_create(

create_message_gas = max_message_call_gas(Uint(evm.gas_left))
evm.gas_left -= create_message_gas
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext
evm.return_data = b""

Expand Down Expand Up @@ -351,7 +351,7 @@ def call(evm: Evm) -> None:
access_gas_cost + create_gas_cost + transfer_gas_cost,
)
charge_gas(evm, message_call_gas.cost + extend_memory.cost)
if not (not evm.message.is_static or value == U256(0)):
if evm.message.is_static and value != U256(0):
raise WriteInStaticContext
evm.memory += b"\x00" * extend_memory.expand_by
sender_balance = get_account(
Expand Down Expand Up @@ -480,7 +480,7 @@ def selfdestruct(evm: Evm) -> None:
gas_cost += GAS_SELF_DESTRUCT_NEW_ACCOUNT

charge_gas(evm, gas_cost)
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext

originator = evm.message.current_target
Expand Down
6 changes: 3 additions & 3 deletions src/ethereum/istanbul/vm/instructions/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def generic_create(

create_message_gas = max_message_call_gas(Uint(evm.gas_left))
evm.gas_left -= create_message_gas
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext
evm.return_data = b""

Expand Down Expand Up @@ -338,7 +338,7 @@ def call(evm: Evm) -> None:
GAS_CALL + create_gas_cost + transfer_gas_cost,
)
charge_gas(evm, message_call_gas.cost + extend_memory.cost)
if not (not evm.message.is_static or value == U256(0)):
if evm.message.is_static and value != U256(0):
raise WriteInStaticContext
evm.memory += b"\x00" * extend_memory.expand_by
sender_balance = get_account(
Expand Down Expand Up @@ -467,7 +467,7 @@ def selfdestruct(evm: Evm) -> None:
evm.refund_counter += REFUND_SELF_DESTRUCT

charge_gas(evm, gas_cost)
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext

beneficiary_balance = get_account(evm.env.state, beneficiary).balance
Expand Down
6 changes: 3 additions & 3 deletions src/ethereum/london/vm/instructions/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def generic_create(

create_message_gas = max_message_call_gas(Uint(evm.gas_left))
evm.gas_left -= create_message_gas
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext
evm.return_data = b""

Expand Down Expand Up @@ -351,7 +351,7 @@ def call(evm: Evm) -> None:
access_gas_cost + create_gas_cost + transfer_gas_cost,
)
charge_gas(evm, message_call_gas.cost + extend_memory.cost)
if not (not evm.message.is_static or value == U256(0)):
if evm.message.is_static and value != U256(0):
raise WriteInStaticContext
evm.memory += b"\x00" * extend_memory.expand_by
sender_balance = get_account(
Expand Down Expand Up @@ -480,7 +480,7 @@ def selfdestruct(evm: Evm) -> None:
gas_cost += GAS_SELF_DESTRUCT_NEW_ACCOUNT

charge_gas(evm, gas_cost)
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext

originator = evm.message.current_target
Expand Down
6 changes: 3 additions & 3 deletions src/ethereum/muir_glacier/vm/instructions/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def generic_create(

create_message_gas = max_message_call_gas(Uint(evm.gas_left))
evm.gas_left -= create_message_gas
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext
evm.return_data = b""

Expand Down Expand Up @@ -338,7 +338,7 @@ def call(evm: Evm) -> None:
GAS_CALL + create_gas_cost + transfer_gas_cost,
)
charge_gas(evm, message_call_gas.cost + extend_memory.cost)
if not (not evm.message.is_static or value == U256(0)):
if evm.message.is_static and value != U256(0):
raise WriteInStaticContext
evm.memory += b"\x00" * extend_memory.expand_by
sender_balance = get_account(
Expand Down Expand Up @@ -467,7 +467,7 @@ def selfdestruct(evm: Evm) -> None:
evm.refund_counter += REFUND_SELF_DESTRUCT

charge_gas(evm, gas_cost)
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext

beneficiary_balance = get_account(evm.env.state, beneficiary).balance
Expand Down
6 changes: 3 additions & 3 deletions src/ethereum/paris/vm/instructions/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def generic_create(

create_message_gas = max_message_call_gas(Uint(evm.gas_left))
evm.gas_left -= create_message_gas
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext
evm.return_data = b""

Expand Down Expand Up @@ -351,7 +351,7 @@ def call(evm: Evm) -> None:
access_gas_cost + create_gas_cost + transfer_gas_cost,
)
charge_gas(evm, message_call_gas.cost + extend_memory.cost)
if not (not evm.message.is_static or value == U256(0)):
if evm.message.is_static and value != U256(0):
raise WriteInStaticContext
evm.memory += b"\x00" * extend_memory.expand_by
sender_balance = get_account(
Expand Down Expand Up @@ -480,7 +480,7 @@ def selfdestruct(evm: Evm) -> None:
gas_cost += GAS_SELF_DESTRUCT_NEW_ACCOUNT

charge_gas(evm, gas_cost)
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext

originator = evm.message.current_target
Expand Down
8 changes: 4 additions & 4 deletions src/ethereum/shanghai/vm/instructions/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ def generic_create(
call_data = memory_read_bytes(
evm.memory, memory_start_position, memory_size
)
if not (len(call_data) <= 2 * MAX_CODE_SIZE):
if len(call_data) > 2 * MAX_CODE_SIZE:
raise OutOfGasError

evm.accessed_addresses.add(contract_address)

create_message_gas = max_message_call_gas(Uint(evm.gas_left))
evm.gas_left -= create_message_gas
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext
evm.return_data = b""

Expand Down Expand Up @@ -374,7 +374,7 @@ def call(evm: Evm) -> None:
access_gas_cost + create_gas_cost + transfer_gas_cost,
)
charge_gas(evm, message_call_gas.cost + extend_memory.cost)
if not (not evm.message.is_static or value == U256(0)):
if evm.message.is_static and value != U256(0):
raise WriteInStaticContext
evm.memory += b"\x00" * extend_memory.expand_by
sender_balance = get_account(
Expand Down Expand Up @@ -503,7 +503,7 @@ def selfdestruct(evm: Evm) -> None:
gas_cost += GAS_SELF_DESTRUCT_NEW_ACCOUNT

charge_gas(evm, gas_cost)
if not (not evm.message.is_static):
if evm.message.is_static:
raise WriteInStaticContext

originator = evm.message.current_target
Expand Down

0 comments on commit 0f116b5

Please sign in to comment.