From d146516acd5bb1534eb6216b2338a1a06315fea0 Mon Sep 17 00:00:00 2001 From: nikolay Date: Mon, 27 Nov 2023 18:44:47 +0200 Subject: [PATCH] Add grandfather contracts ff Signed-off-by: nikolay --- .../hedera-app/src/test/resources/bootstrap.properties | 1 + .../app/service/evm/contracts/execution/EvmProperties.java | 3 +++ .../contracts/operations/HederaEvmOperationsUtilV038.java | 3 ++- .../mono/context/properties/BootstrapProperties.java | 3 +++ .../mono/context/properties/GlobalDynamicProperties.java | 7 +++++++ .../app/service/mono/context/properties/PropertyNames.java | 1 + .../src/main/resources/bootstrap.properties | 1 + .../src/test/resources/bootstrap.properties | 1 + .../src/test/resources/bootstrap/standard.properties | 1 + .../test-clients/src/main/resource/bootstrap.properties | 1 + 10 files changed, 21 insertions(+), 1 deletion(-) diff --git a/hedera-node/hedera-app/src/test/resources/bootstrap.properties b/hedera-node/hedera-app/src/test/resources/bootstrap.properties index ab2446354dc3..55da71c634e8 100644 --- a/hedera-node/hedera-app/src/test/resources/bootstrap.properties +++ b/hedera-node/hedera-app/src/test/resources/bootstrap.properties @@ -75,6 +75,7 @@ contracts.evm.version=v0.45 contracts.evm.version.dynamic=false contracts.permittedDelegateCallers=1062787,1461860 contracts.freeStorageTierLimit=100 +contracts.grandfatherContracts=999999999999999991,999999999999999999 contracts.itemizeStorageFees=true contracts.keys.legacyActivations=1058134by[1062784] contracts.knownBlockHash= diff --git a/hedera-node/hedera-evm/src/main/java/com/hedera/node/app/service/evm/contracts/execution/EvmProperties.java b/hedera-node/hedera-evm/src/main/java/com/hedera/node/app/service/evm/contracts/execution/EvmProperties.java index bc656f0ff54e..d44615240cd3 100644 --- a/hedera-node/hedera-evm/src/main/java/com/hedera/node/app/service/evm/contracts/execution/EvmProperties.java +++ b/hedera-node/hedera-evm/src/main/java/com/hedera/node/app/service/evm/contracts/execution/EvmProperties.java @@ -16,6 +16,7 @@ package com.hedera.node.app.service.evm.contracts.execution; +import java.util.Set; import org.apache.tuweni.bytes.Bytes32; import org.hyperledger.besu.datatypes.Address; @@ -41,4 +42,6 @@ public interface EvmProperties { boolean isCreate2Enabled(); boolean allowCallsToNonContractAccounts(); + + Set
grandfatherContracts(); } diff --git a/hedera-node/hedera-evm/src/main/java/com/hedera/node/app/service/evm/contracts/operations/HederaEvmOperationsUtilV038.java b/hedera-node/hedera-evm/src/main/java/com/hedera/node/app/service/evm/contracts/operations/HederaEvmOperationsUtilV038.java index 1f2f38a583e0..81d83f38c96b 100644 --- a/hedera-node/hedera-evm/src/main/java/com/hedera/node/app/service/evm/contracts/operations/HederaEvmOperationsUtilV038.java +++ b/hedera-node/hedera-evm/src/main/java/com/hedera/node/app/service/evm/contracts/operations/HederaEvmOperationsUtilV038.java @@ -62,7 +62,8 @@ static Operation.OperationResult addressCheckExecution( return systemAccountExecutionSupplier.get(); } if (!evmProperties.evmVersion().equals(EVM_VERSION_0_45) - || !evmProperties.allowCallsToNonContractAccounts()) { + || !evmProperties.allowCallsToNonContractAccounts() + || evmProperties.grandfatherContracts().contains(frame.getContractAddress())) { if (Boolean.FALSE.equals(addressValidator.test(address, frame))) { return new Operation.OperationResult( supplierHaltGasCost.getAsLong(), HederaExceptionalHaltReason.INVALID_SOLIDITY_ADDRESS); diff --git a/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/context/properties/BootstrapProperties.java b/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/context/properties/BootstrapProperties.java index d6f39a47d33d..8d41a2de051b 100644 --- a/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/context/properties/BootstrapProperties.java +++ b/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/context/properties/BootstrapProperties.java @@ -72,6 +72,7 @@ import static com.hedera.node.app.service.mono.context.properties.PropertyNames.CONTRACTS_EVM_ALLOW_CALLS_TO_NON_CONTRACT_ACCOUNTS; import static com.hedera.node.app.service.mono.context.properties.PropertyNames.CONTRACTS_EVM_VERSION; import static com.hedera.node.app.service.mono.context.properties.PropertyNames.CONTRACTS_FREE_STORAGE_TIER_LIMIT; +import static com.hedera.node.app.service.mono.context.properties.PropertyNames.CONTRACTS_GRANDFATHER_CONTRACTS; import static com.hedera.node.app.service.mono.context.properties.PropertyNames.CONTRACTS_ITEMIZE_STORAGE_FEES; import static com.hedera.node.app.service.mono.context.properties.PropertyNames.CONTRACTS_KEYS_LEGACY_ACTIVATIONS; import static com.hedera.node.app.service.mono.context.properties.PropertyNames.CONTRACTS_KNOWN_BLOCK_HASH; @@ -452,6 +453,7 @@ public String getRawValue(final String name) { CACHE_RECORDS_TTL, CONTRACTS_DEFAULT_LIFETIME, CONTRACTS_PERMITTED_DELEGATE_CALLERS, + CONTRACTS_GRANDFATHER_CONTRACTS, CONTRACTS_KEYS_LEGACY_ACTIVATIONS, CONTRACTS_ENFORCE_CREATION_THROTTLE, CONTRACTS_KNOWN_BLOCK_HASH, @@ -764,6 +766,7 @@ public static Function transformFor(final String prop) { entry(TOPICS_MAX_NUM, AS_LONG), entry(CONTRACTS_MAX_NUM, AS_LONG), entry(CONTRACTS_PERMITTED_DELEGATE_CALLERS, AS_EVM_ADDRESSES), + entry(CONTRACTS_GRANDFATHER_CONTRACTS, AS_EVM_ADDRESSES), entry(CONTRACTS_KEYS_LEGACY_ACTIVATIONS, AS_LEGACY_ACTIVATIONS), entry(CONTRACTS_KNOWN_BLOCK_HASH, AS_KNOWN_BLOCK_VALUES), entry(CONTRACTS_LOCAL_CALL_EST_RET_BYTES, AS_INT), diff --git a/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/context/properties/GlobalDynamicProperties.java b/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/context/properties/GlobalDynamicProperties.java index b6db6d140ec1..6e1399973e88 100644 --- a/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/context/properties/GlobalDynamicProperties.java +++ b/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/context/properties/GlobalDynamicProperties.java @@ -45,6 +45,7 @@ import static com.hedera.node.app.service.mono.context.properties.PropertyNames.CONTRACTS_EVM_ALLOW_CALLS_TO_NON_CONTRACT_ACCOUNTS; import static com.hedera.node.app.service.mono.context.properties.PropertyNames.CONTRACTS_EVM_VERSION; import static com.hedera.node.app.service.mono.context.properties.PropertyNames.CONTRACTS_FREE_STORAGE_TIER_LIMIT; +import static com.hedera.node.app.service.mono.context.properties.PropertyNames.CONTRACTS_GRANDFATHER_CONTRACTS; import static com.hedera.node.app.service.mono.context.properties.PropertyNames.CONTRACTS_ITEMIZE_STORAGE_FEES; import static com.hedera.node.app.service.mono.context.properties.PropertyNames.CONTRACTS_KEYS_LEGACY_ACTIVATIONS; import static com.hedera.node.app.service.mono.context.properties.PropertyNames.CONTRACTS_KNOWN_BLOCK_HASH; @@ -297,6 +298,7 @@ public class GlobalDynamicProperties implements EvmProperties { private boolean cryptoCreateWithAliasEnabled; private boolean enforceContractCreationThrottle; private Set
permittedDelegateCallers; + private Set
grandfatherContracts; private EntityScaleFactors entityScaleFactors; private long maxNumWithHapiSigsAccess; private int maxAutoAssociations; @@ -455,6 +457,7 @@ public void reload() { enforceContractCreationThrottle = properties.getBooleanProperty(CONTRACTS_ENFORCE_CREATION_THROTTLE); entityScaleFactors = properties.getEntityScaleFactorsProperty(FEES_PERCENT_UTILIZATION_SCALE_FACTORS); permittedDelegateCallers = properties.getEvmAddresses(CONTRACTS_PERMITTED_DELEGATE_CALLERS); + grandfatherContracts = properties.getEvmAddresses(CONTRACTS_GRANDFATHER_CONTRACTS); legacyContractIdActivations = properties.getLegacyActivationsProperty(CONTRACTS_KEYS_LEGACY_ACTIVATIONS); contractsWithSpecialHapiSigsAccess = properties.getEvmAddresses(CONTRACTS_WITH_SPECIAL_HAPI_SIGS_ACCESS); maxNumWithHapiSigsAccess = properties.getLongProperty(CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS); @@ -955,6 +958,10 @@ public Set
permittedDelegateCallers() { return permittedDelegateCallers; } + public Set
grandfatherContracts() { + return grandfatherContracts; + } + public Set systemContractsWithTopLevelSigsAccess() { return systemContractsWithTopLevelSigsAccess; } diff --git a/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/context/properties/PropertyNames.java b/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/context/properties/PropertyNames.java index fb571af7ad27..ad5c536695fa 100644 --- a/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/context/properties/PropertyNames.java +++ b/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/context/properties/PropertyNames.java @@ -89,6 +89,7 @@ private PropertyNames() { public static final String CONTRACTS_ITEMIZE_STORAGE_FEES = "contracts.itemizeStorageFees"; public static final String CONTRACTS_PERMITTED_DELEGATE_CALLERS = "contracts.permittedDelegateCallers"; + public static final String CONTRACTS_GRANDFATHER_CONTRACTS = "contracts.grandfatherContracts"; public static final String CONTRACTS_REFERENCE_SLOT_LIFETIME = "contracts.referenceSlotLifetime"; public static final String CONTRACTS_FREE_STORAGE_TIER_LIMIT = "contracts.freeStorageTierLimit"; public static final String CONTRACTS_STORAGE_SLOT_PRICE_TIERS = "contract.storageSlotPriceTiers"; diff --git a/hedera-node/hedera-mono-service/src/main/resources/bootstrap.properties b/hedera-node/hedera-mono-service/src/main/resources/bootstrap.properties index 429cc1610ba4..b51f91932293 100644 --- a/hedera-node/hedera-mono-service/src/main/resources/bootstrap.properties +++ b/hedera-node/hedera-mono-service/src/main/resources/bootstrap.properties @@ -75,6 +75,7 @@ contracts.evm.version=v0.45 contracts.evm.version.dynamic=false contracts.permittedDelegateCallers=1062787,1461860 contracts.freeStorageTierLimit=100 +contracts.grandfatherContracts=999999999999999991,999999999999999999 contracts.itemizeStorageFees=true contracts.keys.legacyActivations=1058134by[1062784] # Of historical interest only---block 33476932 was the "synchronization block" used to align the consensus diff --git a/hedera-node/hedera-mono-service/src/test/resources/bootstrap.properties b/hedera-node/hedera-mono-service/src/test/resources/bootstrap.properties index 42a597178aa9..362d73346724 100644 --- a/hedera-node/hedera-mono-service/src/test/resources/bootstrap.properties +++ b/hedera-node/hedera-mono-service/src/test/resources/bootstrap.properties @@ -74,6 +74,7 @@ contracts.evm.allowCallsToNonContractAccounts=true contracts.evm.version=v0.45 contracts.permittedDelegateCallers=1062787,1461860 contracts.freeStorageTierLimit=100 +contracts.grandfatherContracts=999999999999999991,999999999999999999 contracts.itemizeStorageFees=true contracts.keys.legacyActivations=1058134by[1062784] contracts.knownBlockHash= diff --git a/hedera-node/hedera-mono-service/src/test/resources/bootstrap/standard.properties b/hedera-node/hedera-mono-service/src/test/resources/bootstrap/standard.properties index 81450e8f97e1..0f057127f0ce 100644 --- a/hedera-node/hedera-mono-service/src/test/resources/bootstrap/standard.properties +++ b/hedera-node/hedera-mono-service/src/test/resources/bootstrap/standard.properties @@ -75,6 +75,7 @@ contracts.evm.version=v0.45 contracts.evm.version.dynamic=false contracts.permittedDelegateCallers=1062787,1461860 contracts.freeStorageTierLimit=100 +contracts.grandfatherContracts=999999999999999991,999999999999999999 contracts.itemizeStorageFees=true contracts.keys.legacyActivations=1058134by[1062784] contracts.knownBlockHash= diff --git a/hedera-node/test-clients/src/main/resource/bootstrap.properties b/hedera-node/test-clients/src/main/resource/bootstrap.properties index ec923c5b9d23..5bc20d5a4a0b 100644 --- a/hedera-node/test-clients/src/main/resource/bootstrap.properties +++ b/hedera-node/test-clients/src/main/resource/bootstrap.properties @@ -73,6 +73,7 @@ contracts.evm.version=v0.45 contracts.evm.version.dynamic=false contracts.permittedDelegateCallers=1062787,1461860 contracts.freeStorageTierLimit=100 +contracts.grandfatherContracts=999999999999999991,999999999999999999 contracts.itemizeStorageFees=true contracts.keys.legacyActivations=1058134by[1062784] contracts.knownBlockHash=