From 0f116b58173d3871c98dabec0163b216b463288e Mon Sep 17 00:00:00 2001 From: Sam Wilson Date: Fri, 26 Apr 2024 20:42:28 -0400 Subject: [PATCH] Clean up conditionals in vm/instructions/system.py --- src/ethereum/arrow_glacier/vm/instructions/system.py | 6 +++--- src/ethereum/berlin/vm/instructions/system.py | 6 +++--- src/ethereum/byzantium/vm/instructions/system.py | 6 +++--- src/ethereum/cancun/vm/instructions/system.py | 8 ++++---- src/ethereum/constantinople/vm/instructions/system.py | 6 +++--- src/ethereum/gray_glacier/vm/instructions/system.py | 6 +++--- src/ethereum/istanbul/vm/instructions/system.py | 6 +++--- src/ethereum/london/vm/instructions/system.py | 6 +++--- src/ethereum/muir_glacier/vm/instructions/system.py | 6 +++--- src/ethereum/paris/vm/instructions/system.py | 6 +++--- src/ethereum/shanghai/vm/instructions/system.py | 8 ++++---- 11 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/ethereum/arrow_glacier/vm/instructions/system.py b/src/ethereum/arrow_glacier/vm/instructions/system.py index 2a63fb46a3..986b091c52 100644 --- a/src/ethereum/arrow_glacier/vm/instructions/system.py +++ b/src/ethereum/arrow_glacier/vm/instructions/system.py @@ -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"" @@ -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( @@ -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 diff --git a/src/ethereum/berlin/vm/instructions/system.py b/src/ethereum/berlin/vm/instructions/system.py index 6068bf40ea..168f6ef7b7 100644 --- a/src/ethereum/berlin/vm/instructions/system.py +++ b/src/ethereum/berlin/vm/instructions/system.py @@ -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"" @@ -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( @@ -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 diff --git a/src/ethereum/byzantium/vm/instructions/system.py b/src/ethereum/byzantium/vm/instructions/system.py index 52376001e2..8bb0efd958 100644 --- a/src/ethereum/byzantium/vm/instructions/system.py +++ b/src/ethereum/byzantium/vm/instructions/system.py @@ -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"" @@ -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( @@ -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 diff --git a/src/ethereum/cancun/vm/instructions/system.py b/src/ethereum/cancun/vm/instructions/system.py index 366437dc55..fa0e181775 100644 --- a/src/ethereum/cancun/vm/instructions/system.py +++ b/src/ethereum/cancun/vm/instructions/system.py @@ -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"" @@ -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( @@ -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 diff --git a/src/ethereum/constantinople/vm/instructions/system.py b/src/ethereum/constantinople/vm/instructions/system.py index 7cdbbd683a..03d0d6168b 100644 --- a/src/ethereum/constantinople/vm/instructions/system.py +++ b/src/ethereum/constantinople/vm/instructions/system.py @@ -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"" @@ -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( @@ -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 diff --git a/src/ethereum/gray_glacier/vm/instructions/system.py b/src/ethereum/gray_glacier/vm/instructions/system.py index 2a63fb46a3..986b091c52 100644 --- a/src/ethereum/gray_glacier/vm/instructions/system.py +++ b/src/ethereum/gray_glacier/vm/instructions/system.py @@ -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"" @@ -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( @@ -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 diff --git a/src/ethereum/istanbul/vm/instructions/system.py b/src/ethereum/istanbul/vm/instructions/system.py index 7cdbbd683a..03d0d6168b 100644 --- a/src/ethereum/istanbul/vm/instructions/system.py +++ b/src/ethereum/istanbul/vm/instructions/system.py @@ -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"" @@ -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( @@ -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 diff --git a/src/ethereum/london/vm/instructions/system.py b/src/ethereum/london/vm/instructions/system.py index 2a63fb46a3..986b091c52 100644 --- a/src/ethereum/london/vm/instructions/system.py +++ b/src/ethereum/london/vm/instructions/system.py @@ -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"" @@ -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( @@ -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 diff --git a/src/ethereum/muir_glacier/vm/instructions/system.py b/src/ethereum/muir_glacier/vm/instructions/system.py index 7cdbbd683a..03d0d6168b 100644 --- a/src/ethereum/muir_glacier/vm/instructions/system.py +++ b/src/ethereum/muir_glacier/vm/instructions/system.py @@ -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"" @@ -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( @@ -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 diff --git a/src/ethereum/paris/vm/instructions/system.py b/src/ethereum/paris/vm/instructions/system.py index 2a63fb46a3..986b091c52 100644 --- a/src/ethereum/paris/vm/instructions/system.py +++ b/src/ethereum/paris/vm/instructions/system.py @@ -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"" @@ -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( @@ -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 diff --git a/src/ethereum/shanghai/vm/instructions/system.py b/src/ethereum/shanghai/vm/instructions/system.py index c936936bc4..ea7463104d 100644 --- a/src/ethereum/shanghai/vm/instructions/system.py +++ b/src/ethereum/shanghai/vm/instructions/system.py @@ -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"" @@ -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( @@ -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