diff --git a/build.gradle.kts b/build.gradle.kts index 5915222d8d..47f50bc4be 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -62,7 +62,7 @@ dependencies { api("com.graphql-java-generator:graphql-java-client-runtime:2.8") api("com.graphql-java:graphql-java-extended-scalars:22.0") api("com.graphql-java:graphql-java-extended-validation:22.0") - api("com.hedera.hashgraph:app:0.57.3") + api("com.hedera.hashgraph:app:0.58.3") api("com.hedera.evm:hedera-evm:0.54.2") api("com.hedera.hashgraph:hedera-protobuf-java-api:0.57.3") api("com.hedera.hashgraph:sdk:2.46.0") @@ -105,6 +105,7 @@ dependencies { api("uk.org.webcompere:system-stubs-jupiter:2.1.7") api("org.web3j:core:4.12.2") api("tech.pegasys:jc-kzg-4844:1.0.0") + api("com.hedera.cryptography:hedera-cryptography-bls:0.1.1-SNAPSHOT") } } diff --git a/hedera-mirror-web3/build.gradle.kts b/hedera-mirror-web3/build.gradle.kts index 38fa8e41a6..2eb5b86be2 100644 --- a/hedera-mirror-web3/build.gradle.kts +++ b/hedera-mirror-web3/build.gradle.kts @@ -31,6 +31,8 @@ plugins { // dependency val headlongVersion = "6.1.1" +repositories { maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } } + dependencies { implementation(platform("org.springframework.cloud:spring-cloud-dependencies")) implementation(project(":common")) diff --git a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/TokenRelationshipReadableKVState.java b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/TokenRelationshipReadableKVState.java index 6e5d7c2dff..26f2f5f063 100644 --- a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/TokenRelationshipReadableKVState.java +++ b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/TokenRelationshipReadableKVState.java @@ -38,6 +38,7 @@ import java.util.Optional; import java.util.function.Supplier; +@SuppressWarnings("deprecation") @Named public class TokenRelationshipReadableKVState extends AbstractReadableKVState { @@ -103,9 +104,9 @@ private TokenRelation tokenRelationFromEntity( } /** - * For the latest block we have the balance directly as a field in the TokenAccount object. - * For the historical block we need to execute a query to calculate the historical balance, but - * we first need to find the account created timestamp and the token type in order to use the correct repository. + * For the latest block we have the balance directly as a field in the TokenAccount object. For the historical block + * we need to execute a query to calculate the historical balance, but we first need to find the account created + * timestamp and the token type in order to use the correct repository. */ private Supplier getBalance(final TokenAccount tokenAccount, final Optional timestamp) { return Suppliers.memoize(() -> timestamp diff --git a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/components/NetworkInfoImpl.java b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/components/NetworkInfoImpl.java index 6971171a14..f9db0418fc 100644 --- a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/components/NetworkInfoImpl.java +++ b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/components/NetworkInfoImpl.java @@ -18,7 +18,6 @@ import com.hedera.hapi.node.base.AccountID; import com.hedera.hapi.node.base.ServiceEndpoint; -import com.hedera.hapi.node.state.roster.Roster; import com.hedera.pbj.runtime.io.buffer.Bytes; import com.swirlds.state.State; import com.swirlds.state.lifecycle.info.NetworkInfo; @@ -68,11 +67,6 @@ public void updateFrom(State state) { throw new UnsupportedOperationException("Not implemented"); } - @Override - public Roster roster() { - return Roster.DEFAULT; - } - /** * Returns a {@link NodeInfo} that is a complete mock other than the software version present in the given * configuration. @@ -92,7 +86,7 @@ public AccountID accountId() { } @Override - public long stake() { + public long weight() { return 0; } diff --git a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/components/SchemaRegistryImpl.java b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/components/SchemaRegistryImpl.java index e67241b249..9504a34deb 100644 --- a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/components/SchemaRegistryImpl.java +++ b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/components/SchemaRegistryImpl.java @@ -75,12 +75,14 @@ public void migrate( @Nonnull final MirrorNodeState state, @Nonnull final NetworkInfo networkInfo, @Nonnull final StartupNetworks startupNetworks) { + final var config = ConfigurationBuilder.create().build(); migrate( serviceName, state, CURRENT_VERSION, networkInfo, - ConfigurationBuilder.create().build(), + config, + config, new HashMap<>(), new AtomicLong(), startupNetworks); @@ -92,7 +94,8 @@ public void migrate( @Nonnull final MirrorNodeState state, @Nullable final SemanticVersion previousVersion, @Nonnull final NetworkInfo networkInfo, - @Nonnull final Configuration config, + @Nonnull final Configuration appConfig, + @Nonnull final Configuration platformConfig, @Nonnull final Map sharedValues, @Nonnull final AtomicLong nextEntityNum, @Nonnull final StartupNetworks startupNetworks) { @@ -107,13 +110,13 @@ public void migrate( for (final var schema : schemas) { final var applications = - schemaApplications.computeApplications(previousVersion, latestVersion, schema, config); + schemaApplications.computeApplications(previousVersion, latestVersion, schema, appConfig); final var readableStates = state.getReadableStates(serviceName); final var previousStates = new FilteredReadableStates(readableStates, readableStates.stateKeys()); final WritableStates writableStates; final WritableStates newStates; if (applications.contains(STATE_DEFINITIONS)) { - final var redefinedWritableStates = applyStateDefinitions(serviceName, schema, config, state); + final var redefinedWritableStates = applyStateDefinitions(serviceName, schema, appConfig, state); writableStates = redefinedWritableStates.beforeStates(); newStates = redefinedWritableStates.afterStates(); } else { @@ -123,7 +126,8 @@ public void migrate( previousVersion, previousStates, newStates, - config, + appConfig, + platformConfig, networkInfo, nextEntityNum, sharedValues, @@ -148,7 +152,8 @@ public MigrationContext newMigrationContext( @Nullable final SemanticVersion previousVersion, @Nonnull final ReadableStates previousStates, @Nonnull final WritableStates writableStates, - @Nonnull final Configuration config, + @Nonnull final Configuration appConfig, + @Nonnull final Configuration platformConfig, @Nonnull final NetworkInfo networkInfo, @Nonnull final AtomicLong nextEntityNum, @Nonnull final Map sharedValues, @@ -189,8 +194,14 @@ public WritableStates newStates() { @Nonnull @Override - public Configuration configuration() { - return config; + public Configuration appConfig() { + return appConfig; + } + + @Nonnull + @Override + public Configuration platformConfig() { + return platformConfig; } @Override diff --git a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/components/ServiceMigratorImpl.java b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/components/ServiceMigratorImpl.java index 4adaaddf69..86c5146d28 100644 --- a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/components/ServiceMigratorImpl.java +++ b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/components/ServiceMigratorImpl.java @@ -48,16 +48,16 @@ public List doMigrations( @Nonnull ServicesRegistry servicesRegistry, @Nullable SoftwareVersion previousVersion, @Nonnull SoftwareVersion currentVersion, - @Nonnull Configuration nodeConfiguration, - @Nonnull Configuration platformConfiguration, + @Nonnull Configuration appConfig, + @Nonnull Configuration platformConfig, @Nullable NetworkInfo genesisNetworkInfo, @Nonnull Metrics metrics, @Nonnull StartupNetworks startupNetworks) { requireNonNull(state); requireNonNull(servicesRegistry); requireNonNull(currentVersion); - requireNonNull(nodeConfiguration); - requireNonNull(platformConfiguration); + requireNonNull(appConfig); + requireNonNull(platformConfig); requireNonNull(genesisNetworkInfo); requireNonNull(metrics); @@ -69,8 +69,8 @@ public List doMigrations( throw new IllegalArgumentException("Can only be used with ServicesRegistryImpl instances"); } - final AtomicLong prevEntityNum = new AtomicLong( - nodeConfiguration.getConfigData(HederaConfig.class).firstUserEntity() - 1); + final AtomicLong prevEntityNum = + new AtomicLong(appConfig.getConfigData(HederaConfig.class).firstUserEntity() - 1); final Map sharedValues = new HashMap<>(); final var deserializedPbjVersion = Optional.ofNullable(previousVersion) .map(SoftwareVersion::getPbjSemanticVersion) @@ -85,7 +85,8 @@ public List doMigrations( mirrorNodeState, deserializedPbjVersion, genesisNetworkInfo, - platformConfiguration, + appConfig, + platformConfig, sharedValues, prevEntityNum, startupNetworks); diff --git a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/components/StartupNetworksImpl.java b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/components/StartupNetworksImpl.java index a9b8809f73..a1921f5c9a 100644 --- a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/components/StartupNetworksImpl.java +++ b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/components/StartupNetworksImpl.java @@ -17,7 +17,9 @@ package com.hedera.mirror.web3.state.components; import com.hedera.node.internal.network.Network; +import com.swirlds.config.api.Configuration; import com.swirlds.state.lifecycle.StartupNetworks; +import jakarta.annotation.Nonnull; import jakarta.inject.Named; import java.util.Optional; @@ -25,7 +27,7 @@ public class StartupNetworksImpl implements StartupNetworks { @Override - public Network genesisNetworkOrThrow() { + public Network genesisNetworkOrThrow(@Nonnull Configuration platformConfig) { return Network.DEFAULT; } diff --git a/hedera-mirror-web3/src/main/java/com/hedera/services/utils/MiscUtils.java b/hedera-mirror-web3/src/main/java/com/hedera/services/utils/MiscUtils.java index ee1c91b15b..e1e9363fc0 100644 --- a/hedera-mirror-web3/src/main/java/com/hedera/services/utils/MiscUtils.java +++ b/hedera-mirror-web3/src/main/java/com/hedera/services/utils/MiscUtils.java @@ -23,12 +23,10 @@ import static com.hederahashgraph.api.proto.java.HederaFunctionality.ContractCreate; import static com.hederahashgraph.api.proto.java.HederaFunctionality.ContractDelete; import static com.hederahashgraph.api.proto.java.HederaFunctionality.ContractUpdate; -import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoAddLiveHash; import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoApproveAllowance; import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoCreate; import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoDelete; import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoDeleteAllowance; -import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoDeleteLiveHash; import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoTransfer; import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoUpdate; import static com.hederahashgraph.api.proto.java.HederaFunctionality.EthereumTransaction; @@ -70,10 +68,6 @@ public final class MiscUtils { - private MiscUtils() { - throw new UnsupportedOperationException("Utility Class"); - } - public static final Function FUNCTION_EXTRACTOR = trans -> { try { return functionOf(trans); @@ -82,9 +76,13 @@ private MiscUtils() { } }; + private MiscUtils() { + throw new UnsupportedOperationException("Utility Class"); + } + /** - * check TransactionBody and return the HederaFunctionality. This method was moved from MiscUtils. - * NODE_STAKE_UPDATE is not checked in this method, since it is not a user transaction. + * check TransactionBody and return the HederaFunctionality. This method was moved from MiscUtils. NODE_STAKE_UPDATE + * is not checked in this method, since it is not a user transaction. * * @param txn the {@code TransactionBody} * @return one of HederaFunctionality @@ -101,12 +99,10 @@ public static HederaFunctionality functionOf(@NonNull final TransactionBody txn) case CONTRACTUPDATEINSTANCE -> ContractUpdate; case CONTRACTDELETEINSTANCE -> ContractDelete; case ETHEREUMTRANSACTION -> EthereumTransaction; - case CRYPTOADDLIVEHASH -> CryptoAddLiveHash; case CRYPTOAPPROVEALLOWANCE -> CryptoApproveAllowance; case CRYPTODELETEALLOWANCE -> CryptoDeleteAllowance; case CRYPTOCREATEACCOUNT -> CryptoCreate; case CRYPTODELETE -> CryptoDelete; - case CRYPTODELETELIVEHASH -> CryptoDeleteLiveHash; case CRYPTOTRANSFER -> CryptoTransfer; case CRYPTOUPDATEACCOUNT -> CryptoUpdate; case FREEZE -> Freeze; diff --git a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/state/components/NetworkInfoImplTest.java b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/state/components/NetworkInfoImplTest.java index 31ee17930a..82a024626a 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/state/components/NetworkInfoImplTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/state/components/NetworkInfoImplTest.java @@ -20,7 +20,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import com.hedera.hapi.node.base.AccountID; -import com.hedera.hapi.node.state.roster.Roster; import com.hedera.mirror.web3.Web3IntegrationTest; import com.hedera.pbj.runtime.io.buffer.Bytes; import com.swirlds.state.lifecycle.info.NodeInfo; @@ -46,7 +45,7 @@ void testSelfNodeInfo() { assertThat(selfNodeInfo).isNotNull().satisfies(info -> { assertThat(info.nodeId()).isZero(); assertThat(info.accountId()).isEqualTo(AccountID.DEFAULT); - assertThat(info.stake()).isZero(); + assertThat(info.weight()).isZero(); assertThat(info.sigCertBytes()).isEqualTo(Bytes.EMPTY); assertThat(info.gossipEndpoints()).isEmpty(); assertThat(info.hexEncodedPublicKey()).isEmpty(); @@ -59,11 +58,6 @@ void testUpdateFrom() { assertThat(exception.getMessage()).isEqualTo("Not implemented"); } - @Test - void testRoster() { - assertThat(networkInfoImpl.roster()).isEqualTo(Roster.DEFAULT); - } - @Test void testAddressBook() { assertThat(networkInfoImpl.addressBook()).isNotEmpty(); diff --git a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/state/components/SchemaRegistryImplTest.java b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/state/components/SchemaRegistryImplTest.java index 5ca4bfc410..ecb0384947 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/state/components/SchemaRegistryImplTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/state/components/SchemaRegistryImplTest.java @@ -80,13 +80,15 @@ class SchemaRegistryImplTest { @Mock private Codec mockCodec; - private Configuration config; + private Configuration appConfig; + private Configuration platformConfig; private SchemaRegistryImpl schemaRegistry; @BeforeEach void initialize() { schemaRegistry = new SchemaRegistryImpl(schemaApplications); - config = new ConfigProviderImpl().getConfiguration(); + appConfig = new ConfigProviderImpl().getConfiguration(); + platformConfig = new ConfigProviderImpl().getConfiguration(); } @Test @@ -116,7 +118,8 @@ void testMigrateWithSingleSchema() { mirrorNodeState, previousVersion, networkInfo, - config, + appConfig, + platformConfig, new HashMap<>(), new AtomicLong(), startupNetworks); @@ -137,7 +140,8 @@ void testMigrateWithMigrations() { mirrorNodeState, previousVersion, networkInfo, - config, + appConfig, + platformConfig, new HashMap<>(), new AtomicLong(), startupNetworks); @@ -161,7 +165,7 @@ void testMigrateWithStateDefinitions() { StateDefinition stateDefinition = new StateDefinition("STATE", mockCodec, mockCodec, 123, true, false, false); - when(schema.statesToCreate(config)) + when(schema.statesToCreate(appConfig)) .thenReturn(Set.of(stateDefinitionSingleton, stateDefinitionQueue, stateDefinition)); schemaRegistry.register(schema); @@ -170,7 +174,8 @@ void testMigrateWithStateDefinitions() { mirrorNodeState, previousVersion, networkInfo, - config, + appConfig, + platformConfig, new HashMap<>(), new AtomicLong(), startupNetworks); @@ -194,7 +199,8 @@ void testMigrateWithRestartApplication() { mirrorNodeState, previousVersion, networkInfo, - config, + appConfig, + platformConfig, new HashMap<>(), new AtomicLong(), startupNetworks); @@ -209,7 +215,8 @@ void testNewMigrationContext() { previousVersion, readableStates, writableStates, - config, + appConfig, + platformConfig, networkInfo, new AtomicLong(1), EMPTY_MAP, @@ -222,7 +229,8 @@ void testNewMigrationContext() { assertThat(c.previousVersion()).isEqualTo(previousVersion); assertThat(c.previousStates()).isEqualTo(readableStates); assertThat(c.newStates()).isEqualTo(writableStates); - assertThat(c.configuration()).isEqualTo(config); + assertThat(c.appConfig()).isEqualTo(appConfig); + assertThat(c.platformConfig()).isEqualTo(platformConfig); assertThat(c.genesisNetworkInfo()).isEqualTo(networkInfo); assertThat(c.newEntityNum()).isEqualTo(1); assertThat(c.sharedValues()).isEqualTo(EMPTY_MAP); diff --git a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/state/components/StartupNetworksImplTest.java b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/state/components/StartupNetworksImplTest.java index fb8679a2f4..71af41af23 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/state/components/StartupNetworksImplTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/state/components/StartupNetworksImplTest.java @@ -18,8 +18,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.mockito.Mockito.mock; import com.hedera.node.internal.network.Network; +import com.swirlds.config.api.Configuration; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -34,7 +36,8 @@ void setUp() { @Test void testGenesisNetworkOrThrow() { - assertThat(startupNetworks.genesisNetworkOrThrow()).isEqualTo(Network.DEFAULT); + assertThat(startupNetworks.genesisNetworkOrThrow(mock(Configuration.class))) + .isEqualTo(Network.DEFAULT); } @Test diff --git a/hedera-mirror-web3/src/test/java/com/hedera/services/utils/MiscUtilsTest.java b/hedera-mirror-web3/src/test/java/com/hedera/services/utils/MiscUtilsTest.java index f850b18cc1..cf8da8c5e8 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/services/utils/MiscUtilsTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/services/utils/MiscUtilsTest.java @@ -23,11 +23,9 @@ import static com.hederahashgraph.api.proto.java.HederaFunctionality.ContractCreate; import static com.hederahashgraph.api.proto.java.HederaFunctionality.ContractDelete; import static com.hederahashgraph.api.proto.java.HederaFunctionality.ContractUpdate; -import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoAddLiveHash; import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoApproveAllowance; import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoCreate; import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoDelete; -import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoDeleteLiveHash; import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoTransfer; import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoUpdate; import static com.hederahashgraph.api.proto.java.HederaFunctionality.EthereumTransaction; @@ -58,10 +56,8 @@ import com.hederahashgraph.api.proto.java.ContractCreateTransactionBody; import com.hederahashgraph.api.proto.java.ContractDeleteTransactionBody; import com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody; -import com.hederahashgraph.api.proto.java.CryptoAddLiveHashTransactionBody; import com.hederahashgraph.api.proto.java.CryptoApproveAllowanceTransactionBody; import com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody; -import com.hederahashgraph.api.proto.java.CryptoDeleteLiveHashTransactionBody; import com.hederahashgraph.api.proto.java.CryptoDeleteTransactionBody; import com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody; import com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody; @@ -169,10 +165,8 @@ void getsExpectedTxnFunctionality() { put(ContractCreate, new BodySetter<>(ContractCreateTransactionBody.class)); put(EthereumTransaction, new BodySetter<>(EthereumTransactionBody.class)); put(ContractUpdate, new BodySetter<>(ContractUpdateTransactionBody.class)); - put(CryptoAddLiveHash, new BodySetter<>(CryptoAddLiveHashTransactionBody.class)); put(CryptoCreate, new BodySetter<>(CryptoCreateTransactionBody.class)); put(CryptoDelete, new BodySetter<>(CryptoDeleteTransactionBody.class)); - put(CryptoDeleteLiveHash, new BodySetter<>(CryptoDeleteLiveHashTransactionBody.class)); put(CryptoTransfer, new BodySetter<>(CryptoTransferTransactionBody.class)); put(CryptoUpdate, new BodySetter<>(CryptoUpdateTransactionBody.class)); put(ContractDelete, new BodySetter<>(ContractDeleteTransactionBody.class));