Skip to content

Commit

Permalink
fix: frontend throttle capacity stop querying the platform for roster
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Gatsanoga <[email protected]>
  • Loading branch information
MiroslavGatsanoga committed Nov 25, 2024
1 parent 11f5f17 commit 0a177a5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -55,12 +54,6 @@ static Supplier<Charset> provideNativeCharset() {
return Charset::defaultCharset;
}

@Provides
@Singleton
static IntSupplier provideFrontendThrottleSplit(@NonNull final Platform platform) {
return () -> platform.getRoster().rosterEntries().size();
}

@Binds
@Singleton
ReconnectCompleteListener bindReconnectListener(ReconnectListener reconnectListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();

Check warning on line 150 in hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/standalone/impl/StandaloneNetworkInfo.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/standalone/impl/StandaloneNetworkInfo.java#L141-L150

Added lines #L141 - L150 were not covered by tests
}

private @NonNull List<NodeInfo> nodeInfosOrThrow() {
Expand Down

0 comments on commit 0a177a5

Please sign in to comment.