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 20a5ea8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 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 @@ -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);
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();
}

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

0 comments on commit 20a5ea8

Please sign in to comment.