diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/platform/PlatformModule.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/platform/PlatformModule.java index 49939859d3e2..612ab0b17371 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/platform/PlatformModule.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/platform/PlatformModule.java @@ -30,7 +30,6 @@ import java.nio.charset.Charset; import java.util.concurrent.ExecutorService; import java.util.concurrent.ForkJoinPool; -import java.util.function.IntSupplier; import java.util.function.Supplier; import javax.inject.Singleton; @@ -55,12 +54,6 @@ static Supplier provideNativeCharset() { return Charset::defaultCharset; } - @Provides - @Singleton - static IntSupplier provideFrontendThrottleSplit(@NonNull final Platform platform) { - return () -> platform.getRoster().rosterEntries().size(); - } - @Binds @Singleton ReconnectCompleteListener bindReconnectListener(ReconnectListener reconnectListener); diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/throttle/ThrottleServiceModule.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/throttle/ThrottleServiceModule.java index dafb463e44ee..0d318d4ebff8 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/throttle/ThrottleServiceModule.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/throttle/ThrottleServiceModule.java @@ -28,6 +28,7 @@ import com.hedera.node.config.ConfigProvider; import com.hedera.node.config.data.FeesConfig; import com.swirlds.metrics.api.Metrics; +import com.swirlds.state.lifecycle.info.NetworkInfo; import dagger.Binds; import dagger.Module; import dagger.Provides; @@ -57,10 +58,12 @@ static ThrottleAccumulator provideBackendThrottleAccumulator(ConfigProvider conf @Singleton @IngestThrottle static ThrottleAccumulator provideIngestThrottleAccumulator( - @NonNull final IntSupplier frontendThrottleSplit, + @NonNull final NetworkInfo networkInfo, @NonNull final ConfigProvider configProvider, @NonNull final Metrics metrics) { final var throttleMetrics = new ThrottleMetrics(metrics, FRONTEND_THROTTLE); + final IntSupplier frontendThrottleSplit = + () -> networkInfo.roster().rosterEntries().size(); return new ThrottleAccumulator(frontendThrottleSplit, configProvider, FRONTEND_THROTTLE, throttleMetrics); } diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/standalone/TransactionExecutors.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/standalone/TransactionExecutors.java index 385feb14129f..5597373f71a6 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/standalone/TransactionExecutors.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/standalone/TransactionExecutors.java @@ -76,8 +76,8 @@ public TransactionExecutor newExecutor( final var tracerBinding = customTracerBinding != null ? customTracerBinding : DefaultTracerBinding.DEFAULT_TRACER_BINDING; final var executor = newExecutorComponent(properties, tracerBinding); - executor.initializer().accept(state); executor.stateNetworkInfo().initFrom(state); + executor.initializer().accept(state); final var exchangeRateManager = executor.exchangeRateManager(); return (transactionBody, consensusNow, operationTracers) -> { final var dispatch = executor.standaloneDispatchFactory().newDispatch(state, transactionBody, consensusNow); diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/standalone/impl/StandaloneNetworkInfo.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/standalone/impl/StandaloneNetworkInfo.java index 8885d13e591f..16b0fc2f6385 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/standalone/impl/StandaloneNetworkInfo.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/standalone/impl/StandaloneNetworkInfo.java @@ -24,6 +24,7 @@ import com.hedera.hapi.node.base.AccountID; import com.hedera.hapi.node.base.NodeAddressBook; import com.hedera.hapi.node.state.roster.Roster; +import com.hedera.hapi.node.state.roster.RosterEntry; import com.hedera.node.app.info.NodeInfoImpl; import com.hedera.node.config.ConfigProvider; import com.hedera.node.config.data.FilesConfig; @@ -35,6 +36,7 @@ import com.swirlds.state.lifecycle.info.NodeInfo; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.Nullable; +import java.util.Comparator; import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; @@ -135,7 +137,17 @@ public void updateFrom(final State state) { @Override public Roster roster() { - throw new UnsupportedOperationException("Not implemented"); + return Roster.newBuilder() + .rosterEntries(nodeInfosOrThrow().stream() + .map(node -> RosterEntry.newBuilder() + .nodeId(node.nodeId()) + .weight(node.stake()) + .gossipCaCertificate(node.sigCertBytes()) + .gossipEndpoint(node.gossipEndpoints()) + .build()) + .sorted(Comparator.comparing(RosterEntry::nodeId)) + .toList()) + .build(); } private @NonNull List nodeInfosOrThrow() {