Skip to content

Commit

Permalink
feat: SCSC metrics for #TXs that fail pureCheck
Browse files Browse the repository at this point in the history
- counts for CONTRACT_CREATE / CONTRACT_CALL / ETHEREUM_TRANSACTION that fail pureCheck for any reason
- and for those that fail pureCheck because they don't even have the intrinsic gas amount
- and for Type 3 format (BLOB) Ethereum transactions (that we don't support)

Signed-off-by: David S Bakin <[email protected]>
  • Loading branch information
david-bakin-sl committed Nov 15, 2024
1 parent b6b6018 commit 30ee588
Show file tree
Hide file tree
Showing 21 changed files with 497 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.hedera.node.app.spi.signatures.SignatureVerifier;
import com.swirlds.common.crypto.Signature;
import com.swirlds.config.api.Configuration;
import com.swirlds.metrics.api.Metrics;
import com.swirlds.state.lifecycle.Service;
import com.swirlds.state.lifecycle.info.NodeInfo;
import edu.umd.cs.findbugs.annotations.NonNull;
Expand Down Expand Up @@ -92,14 +93,23 @@ public Signature sign(final byte[] ledgerId) {
*/
Gossip gossip();

/**
* The metrics provider for the system
*
* @return the metrics provider
*/
Supplier<Metrics> metricsSupplier();

/**
* The active configuration of the application.
*
* @return the configuration
*/
Supplier<Configuration> configSupplier();

/**
* The supplier of the self node info.
*
* @return the supplier
*/
Supplier<NodeInfo> selfNodeInfoSupplier();
Expand Down
1 change: 1 addition & 0 deletions hedera-node/hedera-app-spi/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
requires transitive com.hedera.node.hapi;
requires transitive com.swirlds.common;
requires transitive com.swirlds.config.api;
requires transitive com.swirlds.metrics.api;
requires transitive com.swirlds.state.api;
requires transitive com.hedera.pbj.runtime;
requires static com.github.spotbugs.annotations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import com.hedera.pbj.runtime.io.buffer.Bytes;
import com.swirlds.common.crypto.Hash;
import com.swirlds.common.metrics.noop.NoOpMetrics;
import com.swirlds.metrics.api.Metrics;
import com.swirlds.platform.state.service.PlatformStateService;
import com.swirlds.platform.state.service.schemas.V0540PlatformStateSchema;
import com.swirlds.platform.system.Round;
Expand Down Expand Up @@ -117,18 +118,20 @@ public static void main(String... args) throws Exception {
"blockStream.hashCombineBatchSize", "64",
"blockStream.serializationBatchSize", "32"));
private final List<BlockItem> roundItems = new ArrayList<>();
private final Metrics noopMetrics = new NoOpMetrics();
private final TssBaseServiceImpl tssBaseService = new TssBaseServiceImpl(
new AppContextImpl(
Instant::now,
fakeSignatureVerifier(),
UNAVAILABLE_GOSSIP,
() -> noopMetrics,
() -> configProvider.getConfiguration(),
() -> DEFAULT_NODE_INFO),
ForkJoinPool.commonPool(),
ForkJoinPool.commonPool(),
new PlaceholderTssLibrary(),
ForkJoinPool.commonPool(),
new NoOpMetrics());
noopMetrics);
private final BlockStreamManagerImpl subject = new BlockStreamManagerImpl(
NoopBlockItemWriter::new,
// BaosBlockItemWriter::new,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import com.hedera.pbj.runtime.io.buffer.Bytes;
import com.swirlds.common.crypto.Hash;
import com.swirlds.common.metrics.noop.NoOpMetrics;
import com.swirlds.metrics.api.Metrics;
import com.swirlds.platform.state.service.PlatformStateService;
import com.swirlds.platform.state.service.schemas.V0540PlatformStateSchema;
import com.swirlds.platform.system.Round;
Expand Down Expand Up @@ -93,18 +94,20 @@ public class StandaloneRoundManagement {
private final ConfigProvider configProvider =
new ConfigProviderImpl(false, null, Map.of("blockStream.serializationBatchSize", "32"));
private final List<BlockItem> roundItems = new ArrayList<>();
private final Metrics noopMetrics = new NoOpMetrics();
private final TssBaseServiceImpl tssBaseService = new TssBaseServiceImpl(
new AppContextImpl(
Instant::now,
fakeSignatureVerifier(),
UNAVAILABLE_GOSSIP,
() -> noopMetrics,
() -> configProvider.getConfiguration(),
() -> DEFAULT_NODE_INFO),
ForkJoinPool.commonPool(),
ForkJoinPool.commonPool(),
new PlaceholderTssLibrary(),
ForkJoinPool.commonPool(),
new NoOpMetrics());
noopMetrics);
private final BlockStreamManagerImpl subject = new BlockStreamManagerImpl(
NoopBlockItemWriter::new,
ForkJoinPool.commonPool(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ public Hedera(
new SignatureExpanderImpl(),
new SignatureVerifierImpl(CryptographyHolder.get())),
this,
() -> metrics /* DOES THIS WORK TO DELAY; DOES IT NEED TO BE A REFERENCE? */,

Check warning on line 387 in hedera-node/hedera-app/src/main/java/com/hedera/node/app/Hedera.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-app/src/main/java/com/hedera/node/app/Hedera.java#L387

Added line #L387 was not covered by tests
bootstrapConfigProvider::getConfiguration,
() -> daggerApp.networkInfo().selfNodeInfo());
tssBaseService = tssBaseServiceFactory.apply(appContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.hedera.node.app.spi.AppContext;
import com.hedera.node.app.spi.signatures.SignatureVerifier;
import com.swirlds.config.api.Configuration;
import com.swirlds.metrics.api.Metrics;
import com.swirlds.state.lifecycle.info.NodeInfo;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.time.InstantSource;
Expand All @@ -36,6 +37,7 @@ public record AppContextImpl(
@NonNull InstantSource instantSource,
@NonNull SignatureVerifier signatureVerifier,
@NonNull Gossip gossip,
@NonNull Supplier<Metrics> metricsSupplier,
@NonNull Supplier<Configuration> configSupplier,
@NonNull Supplier<NodeInfo> selfNodeInfoSupplier)
implements AppContext {}
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ public TransactionExecutor newExecutor(
private ExecutorComponent newExecutorComponent(
@NonNull final Map<String, String> properties, @NonNull final TracerBinding tracerBinding) {
final var bootstrapConfigProvider = new BootstrapConfigProviderImpl();
final var noopMetrics = new NoOpMetrics();
final var appContext = new AppContextImpl(
InstantSource.system(),
new AppSignatureVerifier(
bootstrapConfigProvider.getConfiguration().getConfigData(HederaConfig.class),
new SignatureExpanderImpl(),
new SignatureVerifierImpl(CryptographyHolder.get())),
UNAVAILABLE_GOSSIP,
() -> noopMetrics,

Check warning on line 104 in hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/standalone/TransactionExecutors.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/standalone/TransactionExecutors.java#L104

Added line #L104 was not covered by tests
bootstrapConfigProvider::getConfiguration,
() -> DEFAULT_NODE_INFO);
final var tssBaseService = new TssBaseServiceImpl(
Expand All @@ -108,7 +110,7 @@ private ExecutorComponent newExecutorComponent(
ForkJoinPool.commonPool(),
new PlaceholderTssLibrary(),
ForkJoinPool.commonPool(),
new NoOpMetrics());
noopMetrics);
final var contractService = new ContractServiceImpl(appContext, NOOP_VERIFICATION_STRATEGIES, tracerBinding);
final var fileService = new FileServiceImpl();
final var configProvider = new ConfigProviderImpl(false, null, properties);
Expand All @@ -118,7 +120,7 @@ private ExecutorComponent newExecutorComponent(
.tssBaseService(tssBaseService)
.fileServiceImpl(fileService)
.contractServiceImpl(contractService)
.metrics(new NoOpMetrics())
.metrics(noopMetrics)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ void setUp() {
Bytes.wrap("cert7"));

final var configProvider = new ConfigProviderImpl(false);
final var noopMetrics = new NoOpMetrics();
final var appContext = new AppContextImpl(
InstantSource.system(),
new AppSignatureVerifier(
DEFAULT_CONFIG.getConfigData(HederaConfig.class),
new SignatureExpanderImpl(),
new SignatureVerifierImpl(CryptographyHolder.get())),
UNAVAILABLE_GOSSIP,
() -> noopMetrics,
() -> configuration,
() -> DEFAULT_NODE_INFO);
given(tssBaseService.tssHandlers())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,15 @@ private Map<Long, Function<Configuration, Bytes>> genesisContentProviders(

private void registerServices(@NonNull final ServicesRegistry servicesRegistry) {
// Register all service schema RuntimeConstructable factories before platform init
final var noopMetrics = new NoOpMetrics();
Set.of(
new EntityIdService(),
new ConsensusServiceImpl(),
new ContractServiceImpl(new AppContextImpl(
InstantSource.system(),
signatureVerifier,
UNAVAILABLE_GOSSIP,
() -> noopMetrics,
() -> HederaTestConfigBuilder.createConfig(),
() -> DEFAULT_NODE_INFO)),
new FileServiceImpl(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@

package com.hedera.node.app.service.contract.impl;

import com.hedera.node.app.service.contract.impl.exec.metrics.ContractMetrics;
import com.hedera.node.app.service.contract.impl.exec.scope.VerificationStrategies;
import com.hedera.node.app.service.contract.impl.handlers.ContractHandlers;
import com.hedera.node.app.spi.signatures.SignatureVerifier;
import com.swirlds.metrics.api.Metrics;
import dagger.BindsInstance;
import dagger.Component;
import edu.umd.cs.findbugs.annotations.Nullable;
Expand Down Expand Up @@ -50,11 +52,17 @@ ContractServiceComponent create(
@BindsInstance InstantSource instantSource,
@BindsInstance SignatureVerifier signatureVerifier,
@BindsInstance VerificationStrategies verificationStrategies,
@BindsInstance @Nullable Supplier<List<OperationTracer>> addOnTracers);
@BindsInstance @Nullable Supplier<List<OperationTracer>> addOnTracers,
@BindsInstance Supplier<Metrics> metricsSupplier,
@BindsInstance ContractMetrics contractMetrics);
}

/**
* @return all contract transaction handlers
*/
ContractHandlers handlers();

Supplier<Metrics> metricsSupplier();

ContractMetrics contractMetrics();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
import static java.util.Objects.requireNonNull;

import com.hedera.node.app.service.contract.ContractService;
import com.hedera.node.app.service.contract.impl.exec.metrics.ContractMetrics;
import com.hedera.node.app.service.contract.impl.exec.scope.DefaultVerificationStrategies;
import com.hedera.node.app.service.contract.impl.exec.scope.VerificationStrategies;
import com.hedera.node.app.service.contract.impl.handlers.ContractHandlers;
import com.hedera.node.app.service.contract.impl.schemas.V0490ContractSchema;
import com.hedera.node.app.service.contract.impl.schemas.V0500ContractSchema;
import com.hedera.node.app.spi.AppContext;
import com.swirlds.metrics.api.Metrics;
import com.swirlds.state.lifecycle.SchemaRegistry;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
Expand Down Expand Up @@ -68,7 +70,9 @@ public ContractServiceImpl(
// C.f. https://github.com/hashgraph/hedera-services/issues/14248
appContext.signatureVerifier(),
Optional.ofNullable(verificationStrategies).orElseGet(DefaultVerificationStrategies::new),
addOnTracers);
addOnTracers,
appContext.metricsSupplier(),
new ContractMetrics());
}

@Override
Expand All @@ -83,4 +87,13 @@ public void registerSchemas(@NonNull final SchemaRegistry registry) {
public ContractHandlers handlers() {
return component.handlers();
}

public Supplier<Metrics> metricsSupplier() {
return component.metricsSupplier();

Check warning on line 92 in hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/ContractServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/ContractServiceImpl.java#L92

Added line #L92 was not covered by tests
}

public ContractMetrics contractMetrics() {
component.contractMetrics().init(metricsSupplier().get());
return component.contractMetrics();

Check warning on line 97 in hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/ContractServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/ContractServiceImpl.java#L96-L97

Added lines #L96 - L97 were not covered by tests
}
}
Loading

0 comments on commit 30ee588

Please sign in to comment.