diff --git a/hedera-node/docs/design/services/smart-contract-service/evm-versioning.md b/hedera-node/docs/design/services/smart-contract-service/evm-versioning.md index 47bb9405e0b9..d9dde9f2bc09 100644 --- a/hedera-node/docs/design/services/smart-contract-service/evm-versioning.md +++ b/hedera-node/docs/design/services/smart-contract-service/evm-versioning.md @@ -53,7 +53,8 @@ document which major hardfork corresponds to each internal version. |---------------:|:------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `v0.30` | [London](https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/london.md) | | | `v0.34` | [Paris](https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/paris.md) | Replaces `DIFFICULTY` with `RANDAO`, removes errors from Invalid Solidity Addresses. Adds lazy creation (hollow account creation) capabilities in the EVM as per HIP-583. | -| ? | [Shanghai](https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md) | Expected Q2 2023 or later | +| `v0.38` | [Shanghai](https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md) | Adds `PUSH0` opcode needed for solidity compatibility | +| `v0.46` | Shanghai | Change to non-existing call behavior for EVM Equivalence | ## Open Questions @@ -62,6 +63,7 @@ The exact timing of versions that correspond to Ethereum Mainnet forks is out of ## Acceptance Tests Acceptance tests use the Paris re-definition of `DIFFICULTY` as the test for activation + * Test that when dynamic is set to false that changing the version has no effect * Test when dynamic is set to true the evm version can change at each transaction * verify 0.30 still returns zeros for difficulty diff --git a/hedera-node/hedera-evm/src/test/java/com/hedera/node/app/service/evm/contracts/execution/HederaEvmTxProcessorTest.java b/hedera-node/hedera-evm/src/test/java/com/hedera/node/app/service/evm/contracts/execution/HederaEvmTxProcessorTest.java index 114b215dc252..f5d983131a54 100644 --- a/hedera-node/hedera-evm/src/test/java/com/hedera/node/app/service/evm/contracts/execution/HederaEvmTxProcessorTest.java +++ b/hedera-node/hedera-evm/src/test/java/com/hedera/node/app/service/evm/contracts/execution/HederaEvmTxProcessorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Hedera Hashgraph, LLC + * Copyright (C) 2021-2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,6 +98,9 @@ class HederaEvmTxProcessorTest { @Mock private BlockMetaSource blockMetaSource; + @Mock + private EvmConfiguration evmConfiguration; + private final HederaEvmAccount sender = new HederaEvmAccount(Address.fromHexString("0x000000000000000000000000000000000000071e")); private final Address senderAddress = Address.fromHexString("0x000000000000000000000000000000000000070e"); @@ -118,7 +121,9 @@ void setup() { MainnetEVMs.registerLondonOperations(operationRegistry, gasCalculator, BigInteger.ZERO); operations.forEach(operationRegistry::put); when(globalDynamicProperties.evmVersion()).thenReturn(EVM_VERSION_0_30); - final var evm30 = new EVM(operationRegistry, gasCalculator, EvmConfiguration.DEFAULT, EvmSpecVersion.LONDON); + when(evmConfiguration.getJumpDestCacheWeightBytes()) + .thenReturn(EvmConfiguration.DEFAULT.getJumpDestCacheWeightBytes()); + final var evm30 = new EVM(operationRegistry, gasCalculator, evmConfiguration, EvmSpecVersion.LONDON); final Map> mcps = Map.of( EVM_VERSION_0_30, () -> { diff --git a/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/contracts/ContractsV_0_46Module.java b/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/contracts/ContractsV_0_46Module.java index 924586060fc1..a74038d11ef4 100644 --- a/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/contracts/ContractsV_0_46Module.java +++ b/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/contracts/ContractsV_0_46Module.java @@ -290,12 +290,15 @@ static Operation provideSStoreOperation( @Provides @Singleton @V_0_46 - static EVM provideV_0_46EVM(@V_0_46 Set hederaOperations, GasCalculator gasCalculator) { + static EVM provideV_0_46EVM( + @V_0_46 Set hederaOperations, + final EvmConfiguration evmConfiguration, + GasCalculator gasCalculator) { var operationRegistry = new OperationRegistry(); // ChainID will be overridden registerShanghaiOperations(operationRegistry, gasCalculator, BigInteger.ZERO); hederaOperations.forEach(operationRegistry::put); - return new EVM(operationRegistry, gasCalculator, EvmConfiguration.DEFAULT, EvmSpecVersion.SHANGHAI); + return new EVM(operationRegistry, gasCalculator, evmConfiguration, EvmSpecVersion.SHANGHAI); } @Provides diff --git a/hedera-node/hedera-mono-service/src/test/java/com/hedera/node/app/service/mono/contracts/execution/CallEvmTxProcessorTest.java b/hedera-node/hedera-mono-service/src/test/java/com/hedera/node/app/service/mono/contracts/execution/CallEvmTxProcessorTest.java index 3f69d728f410..177d1bfa456f 100644 --- a/hedera-node/hedera-mono-service/src/test/java/com/hedera/node/app/service/mono/contracts/execution/CallEvmTxProcessorTest.java +++ b/hedera-node/hedera-mono-service/src/test/java/com/hedera/node/app/service/mono/contracts/execution/CallEvmTxProcessorTest.java @@ -138,6 +138,9 @@ class CallEvmTxProcessorTest { @Mock private InHandleBlockMetaSource blockMetaSource; + @Mock + private EvmConfiguration evmConfiguration; + private final Account sender = new Account(new Id(0, 0, 1002)); private final Account receiver = new Account(new Id(0, 0, 1006)); private final Account relayer = new Account(new Id(0, 0, 1007)); @@ -159,7 +162,9 @@ void setup() { MainnetEVMs.registerLondonOperations(operationRegistry, gasCalculator, BigInteger.ZERO); operations.forEach(operationRegistry::put); when(globalDynamicProperties.evmVersion()).thenReturn(EVM_VERSION_0_30); - var evm30 = new EVM(operationRegistry, gasCalculator, EvmConfiguration.DEFAULT, EvmSpecVersion.LONDON); + when(evmConfiguration.getJumpDestCacheWeightBytes()) + .thenReturn(EvmConfiguration.DEFAULT.getJumpDestCacheWeightBytes()); + var evm30 = new EVM(operationRegistry, gasCalculator, evmConfiguration, EvmSpecVersion.LONDON); Map> mcps = Map.of( EVM_VERSION_0_30, () -> { @@ -637,7 +642,9 @@ void assertProcessingResourceExhaustionChargesBothSenderAndRelayerWithoutRefunds MainnetEVMs.registerLondonOperations(operationRegistry, gasCalculator, BigInteger.ZERO); operations.forEach(operationRegistry::put); when(globalDynamicProperties.evmVersion()).thenReturn(EVM_VERSION_0_30); - var evm30 = new EVM(operationRegistry, gasCalculator, EvmConfiguration.DEFAULT, EvmSpecVersion.LONDON); + when(evmConfiguration.getJumpDestCacheWeightBytes()) + .thenReturn(EvmConfiguration.DEFAULT.getJumpDestCacheWeightBytes()); + var evm30 = new EVM(operationRegistry, gasCalculator, evmConfiguration, EvmSpecVersion.LONDON); final MessageCallProcessor messageCallProcessor = mock(MessageCallProcessor.class); Map> mcps = Map.of(EVM_VERSION_0_30, () -> messageCallProcessor, EVM_VERSION_0_34, () -> messageCallProcessor); diff --git a/hedera-node/hedera-mono-service/src/test/java/com/hedera/node/app/service/mono/contracts/execution/CallLocalEvmTxProcessorTest.java b/hedera-node/hedera-mono-service/src/test/java/com/hedera/node/app/service/mono/contracts/execution/CallLocalEvmTxProcessorTest.java index 0d239c50aa1a..360e8dfbe860 100644 --- a/hedera-node/hedera-mono-service/src/test/java/com/hedera/node/app/service/mono/contracts/execution/CallLocalEvmTxProcessorTest.java +++ b/hedera-node/hedera-mono-service/src/test/java/com/hedera/node/app/service/mono/contracts/execution/CallLocalEvmTxProcessorTest.java @@ -106,6 +106,9 @@ class CallLocalEvmTxProcessorTest { @Mock private HederaBlockValues hederaBlockValues; + @Mock + private EvmConfiguration evmConfiguration; + private final Account sender = new Account(new Id(0, 0, 1002)); private final Account receiver = new Account(new Id(0, 0, 1006)); private final Address receiverAddress = receiver.getId().asEvmAddress(); @@ -120,7 +123,9 @@ void setup() { MainnetEVMs.registerLondonOperations(operationRegistry, gasCalculator, BigInteger.ZERO); operations.forEach(operationRegistry::put); when(globalDynamicProperties.evmVersion()).thenReturn(EVM_VERSION_0_30); - var evm30 = new EVM(operationRegistry, gasCalculator, EvmConfiguration.DEFAULT, EvmSpecVersion.LONDON); + when(evmConfiguration.getJumpDestCacheWeightBytes()) + .thenReturn(EvmConfiguration.DEFAULT.getJumpDestCacheWeightBytes()); + var evm30 = new EVM(operationRegistry, gasCalculator, evmConfiguration, EvmSpecVersion.LONDON); Map> mcps = Map.of(EVM_VERSION_0_30, () -> new MessageCallProcessor(evm30, new PrecompileContractRegistry())); Map> ccps = diff --git a/hedera-node/hedera-mono-service/src/test/java/com/hedera/node/app/service/mono/contracts/execution/CreateEvmTxProcessorTest.java b/hedera-node/hedera-mono-service/src/test/java/com/hedera/node/app/service/mono/contracts/execution/CreateEvmTxProcessorTest.java index cd62cde8fe12..5116edcc55fd 100644 --- a/hedera-node/hedera-mono-service/src/test/java/com/hedera/node/app/service/mono/contracts/execution/CreateEvmTxProcessorTest.java +++ b/hedera-node/hedera-mono-service/src/test/java/com/hedera/node/app/service/mono/contracts/execution/CreateEvmTxProcessorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Hedera Hashgraph, LLC + * Copyright (C) 2021-2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -106,6 +106,9 @@ class CreateEvmTxProcessorTest { @Mock private AliasManager aliasManager; + @Mock + EvmConfiguration evmConfiguration; + private CreateEvmTxProcessor createEvmTxProcessor; private final Account sender = new Account(new Id(0, 0, 1002)); private final Account receiver = new Account(new Id(0, 0, 1006)); @@ -124,7 +127,9 @@ void setup() { MainnetEVMs.registerLondonOperations(operationRegistry, gasCalculator, BigInteger.ZERO); operations.forEach(operationRegistry::put); when(globalDynamicProperties.evmVersion()).thenReturn(EVM_VERSION_0_30); - var evm30 = new EVM(operationRegistry, gasCalculator, EvmConfiguration.DEFAULT, EvmSpecVersion.LONDON); + when(evmConfiguration.getJumpDestCacheWeightBytes()) + .thenReturn(EvmConfiguration.DEFAULT.getJumpDestCacheWeightBytes()); + var evm30 = new EVM(operationRegistry, gasCalculator, evmConfiguration, EvmSpecVersion.LONDON); Map> mcps = Map.of(EVM_VERSION_0_30, () -> new MessageCallProcessor(evm30, new PrecompileContractRegistry())); Map> ccps = diff --git a/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/v046/V046Module.java b/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/v046/V046Module.java index 9f132e96ce56..aa090a9e3e75 100644 --- a/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/v046/V046Module.java +++ b/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/v046/V046Module.java @@ -74,7 +74,7 @@ /** * Provides the Services 0.46 EVM implementation, which consists of Shanghai operations and - * Instanbul precompiles plus the Hedera gas calculator, system contracts, and operations + * Istanbul precompiles plus the Hedera gas calculator, system contracts, and operations * as they were configured in the 0.46 release (with treatment of calls to non-existing addresses * returning successful results in order to enhance EVM equivalence). */ @@ -125,12 +125,14 @@ static CustomMessageCallProcessor provideMessageCallProcessor( @Singleton @ServicesV046 static EVM provideEVM( - @ServicesV046 @NonNull final Set customOperations, @NonNull final GasCalculator gasCalculator) { - // Use Paris EVM with 0.38 custom operations and 0x00 chain id (set at runtime) + @ServicesV046 @NonNull final Set customOperations, + @NonNull final EvmConfiguration evmConfiguration, + @NonNull final GasCalculator gasCalculator) { + // Use Shanghai EVM with 0.46 custom operations and 0x00 chain id (set at runtime) final var operationRegistry = new OperationRegistry(); registerShanghaiOperations(operationRegistry, gasCalculator, BigInteger.ZERO); customOperations.forEach(operationRegistry::put); - return new EVM(operationRegistry, gasCalculator, EvmConfiguration.DEFAULT, EvmSpecVersion.SHANGHAI); + return new EVM(operationRegistry, gasCalculator, evmConfiguration, EvmSpecVersion.SHANGHAI); } @Provides