Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix javadoc for ethereum api module, graphql package #7272

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 59 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,65 @@ allprojects {
options.addBooleanOption('Xdoclint/package:-org.hyperledger.besu.privacy.contracts.generated,' +
'-org.hyperledger.besu.tests.acceptance.*,' +
'-org.hyperledger.besu.tests.web3j.generated,' +
// TODO: these are temporary disabled (ethereum and sub modules), it should be removed in a future PR.
'-org.hyperledger.besu.ethereum.*,' +
'-org.hyperledger.besu.evmtool',
// TODO: these are temporary excluded from lint (ethereum sub modules), it should be removed in a future PR.
// ethereum api module
'-org.hyperledger.besu.ethereum.api.handlers,' +
'-org.hyperledger.besu.ethereum.api.jsonrpc,' +
'-org.hyperledger.besu.ethereum.api.jsonrpc.*,' +
'-org.hyperledger.besu.ethereum.api.query,' +
'-org.hyperledger.besu.ethereum.api.query.*,' +
'-org.hyperledger.besu.ethereum.api.tls,' +
'-org.hyperledger.besu.ethereum.api.util,' +
// ethereum blockcreation module
'-org.hyperledger.besu.ethereum.blockcreation,' +
'-org.hyperledger.besu.ethereum.blockcreation.*,' +
// ethereum core module
'-org.hyperledger.besu.ethereum.chain,' +
'-org.hyperledger.besu.ethereum.core,' +
'-org.hyperledger.besu.ethereum.core.*,' +
'-org.hyperledger.besu.ethereum.debug,' +
'-org.hyperledger.besu.ethereum.difficulty.fixed,' +
'-org.hyperledger.besu.ethereum.forkid,' +
'-org.hyperledger.besu.ethereum.mainnet,' +
'-org.hyperledger.besu.ethereum.mainnet.*,' +
'-org.hyperledger.besu.ethereum.privacy,' +
'-org.hyperledger.besu.ethereum.privacy.*,' +
'-org.hyperledger.besu.ethereum.processing,' +
'-org.hyperledger.besu.ethereum.proof,' +
'-org.hyperledger.besu.ethereum.storage,' +
'-org.hyperledger.besu.ethereum.storage.*,' +
'-org.hyperledger.besu.ethereum.transaction,' +
'-org.hyperledger.besu.ethereum.trie.*,' +
'-org.hyperledger.besu.ethereum.util,' +
'-org.hyperledger.besu.ethereum.vm,' +
'-org.hyperledger.besu.ethereum.worldstate,' +
// ethereum eth module
'-org.hyperledger.besu.ethereum.eth.*,' +
'-org.hyperledger.besu.ethereum.eth,' +
'-org.hyperledger.besu.consensus.merge,' +
// evmtool module
'-org.hyperledger.besu.evmtool,' +
// p2p module
'-org.hyperledger.besu.ethereum.p2p,' +
'-org.hyperledger.besu.ethereum.p2p.*,' +
// permissioning module
'-org.hyperledger.besu.ethereum.permissioning,' +
'-org.hyperledger.besu.ethereum.permissioning.*,' +
// referencetests module
'-org.hyperledger.besu.ethereum.referencetests,' +
// retesteth module
'-org.hyperledger.besu.ethereum.retesteth.methods,' +
'-org.hyperledger.besu.ethereum.retesteth,' +
//rlp module
'-org.hyperledger.besu.ethereum.rlp,' +
// stratum module
'-org.hyperledger.besu.ethereum.stratum,' +
// trie module
'-org.hyperledger.besu.ethereum.trie.*,' +
'-org.hyperledger.besu.ethereum.trie,' +
// verkle trie module
'-org.hyperledger.besu.ethereum.verkletrie,' +
'-org.hyperledger.besu.ethereum.verkletrie.*',
true)
options.addStringOption('Xmaxerrs','65535')
options.addStringOption('Xmaxwarns','65535')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,58 +18,125 @@

import org.immutables.value.Value;

/**
* The ApiConfiguration class provides configuration for the API. It includes default values for gas
* price, max logs range, gas cap, and other parameters.
*/
@Value.Immutable
@Value.Style(allParameters = true)
public abstract class ApiConfiguration {

/**
* The default lower bound coefficient for gas and priority fee. This value is used as the default
* lower bound when calculating the gas and priority fee.
*/
public static final long DEFAULT_LOWER_BOUND_GAS_AND_PRIORITY_FEE_COEFFICIENT = 0L;

/**
* The default upper bound coefficient for gas and priority fee. This value is used as the default
* upper bound when calculating the gas and priority fee.
*/
public static final long DEFAULT_UPPER_BOUND_GAS_AND_PRIORITY_FEE_COEFFICIENT = Long.MAX_VALUE;

/** Constructs a new ApiConfiguration with default values. */
protected ApiConfiguration() {}

/**
* Returns the number of blocks to consider for gas price calculations. Default value is 100.
*
* @return the number of blocks for gas price calculations
*/
@Value.Default
public long getGasPriceBlocks() {
return 100;
}

/**
* Returns the percentile to use for gas price calculations. Default value is 50.0.
*
* @return the percentile for gas price calculations
*/
@Value.Default
public double getGasPricePercentile() {
return 50.0d;
}

/**
* Returns the maximum gas price. Default value is 500 GWei.
*
* @return the maximum gas price
*/
@Value.Default
public Wei getGasPriceMax() {
return Wei.of(500_000_000_000L); // 500 GWei
}

/**
* Returns the fraction to use for gas price calculations. This is derived from the gas price
* percentile.
*
* @return the fraction for gas price calculations
*/
@Value.Derived
public double getGasPriceFraction() {
return getGasPricePercentile() / 100.0;
}

/**
* Returns the maximum range for logs. Default value is 5000.
*
* @return the maximum range for logs
*/
@Value.Default
public Long getMaxLogsRange() {
return 5000L;
}

/**
* Returns the gas cap. Default value is 0.
*
* @return the gas cap
*/
@Value.Default
public Long getGasCap() {
return 0L;
}

/**
* Returns whether gas and priority fee limiting is enabled. Default value is false.
*
* @return true if gas and priority fee limiting is enabled, false otherwise
*/
@Value.Default
public boolean isGasAndPriorityFeeLimitingEnabled() {
return false;
}

/**
* Returns the lower bound coefficient for gas and priority fee. Default value is 0.
*
* @return the lower bound coefficient for gas and priority fee
*/
@Value.Default
public Long getLowerBoundGasAndPriorityFeeCoefficient() {
return DEFAULT_LOWER_BOUND_GAS_AND_PRIORITY_FEE_COEFFICIENT;
}

/**
* Returns the upper bound coefficient for gas and priority fee. Default value is Long.MAX_VALUE.
*
* @return the upper bound coefficient for gas and priority fee
*/
@Value.Default
public Long getUpperBoundGasAndPriorityFeeCoefficient() {
return DEFAULT_UPPER_BOUND_GAS_AND_PRIORITY_FEE_COEFFICIENT;
}

/**
* Returns the maximum range for trace filter. Default value is 1000.
*
* @return the maximum range for trace filter
*/
@Value.Default
public Long getMaxTraceFilterRange() {
return 1000L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,33 @@

import com.google.common.base.MoreObjects;

/**
* Represents the configuration for GraphQL. This class is used to set and get the configuration
* details for GraphQL such as enabling GraphQL, setting the port and host, setting the allowed
* domains for CORS, setting the hosts allowlist, and setting the HTTP timeout.
*/
public class GraphQLConfiguration {
private static final String DEFAULT_GRAPHQL_HTTP_HOST = "127.0.0.1";

/** The default port number for the GraphQL HTTP server. */
public static final int DEFAULT_GRAPHQL_HTTP_PORT = 8547;

private boolean enabled;
private int port;
private String host;
private List<String> corsAllowedDomains = Collections.emptyList();
private List<String> hostsAllowlist = Arrays.asList("localhost", "127.0.0.1");
private List<String> hostsAllowlist = Arrays.asList("localhost", DEFAULT_GRAPHQL_HTTP_HOST);
private long httpTimeoutSec = TimeoutOptions.defaultOptions().getTimeoutSeconds();

/**
* Creates a default configuration for GraphQL.
*
* <p>This method initializes a new GraphQLConfiguration object with default settings. The default
* settings are: - GraphQL is not enabled - The port is set to the default GraphQL HTTP port - The
* host is set to the default GraphQL HTTP host - The HTTP timeout is set to the default timeout
*
* @return a GraphQLConfiguration object with default settings
*/
public static GraphQLConfiguration createDefault() {
final GraphQLConfiguration config = new GraphQLConfiguration();
config.setEnabled(false);
Expand All @@ -48,52 +64,112 @@ public static GraphQLConfiguration createDefault() {

private GraphQLConfiguration() {}

/**
* Checks if GraphQL is enabled.
*
* @return true if GraphQL is enabled, false otherwise
*/
public boolean isEnabled() {
return enabled;
}

/**
* Sets the enabled status of GraphQL.
*
* @param enabled the status to set. true to enable GraphQL, false to disable it
*/
public void setEnabled(final boolean enabled) {
this.enabled = enabled;
}

/**
* Retrieves the port number for the GraphQL HTTP server.
*
* @return the port number
*/
public int getPort() {
return port;
}

/**
* Sets the port number for the GraphQL HTTP server.
*
* @param port the port number to set
*/
public void setPort(final int port) {
this.port = port;
}

/**
* Retrieves the host for the GraphQL HTTP server.
*
* @return the host
*/
public String getHost() {
return host;
}

/**
* Sets the host for the GraphQL HTTP server.
*
* @param host the host to set
*/
public void setHost(final String host) {
this.host = host;
}

/**
* Retrieves the allowed domains for CORS.
*
* @return a collection of allowed domains for CORS
*/
Collection<String> getCorsAllowedDomains() {
return corsAllowedDomains;
}

/**
* Sets the allowed domains for CORS.
*
* @param corsAllowedDomains a list of allowed domains for CORS
*/
public void setCorsAllowedDomains(final List<String> corsAllowedDomains) {
checkNotNull(corsAllowedDomains);
this.corsAllowedDomains = corsAllowedDomains;
}

/**
* Retrieves the hosts allowlist.
*
* @return a collection of hosts in the allowlist
*/
Collection<String> getHostsAllowlist() {
return Collections.unmodifiableCollection(this.hostsAllowlist);
}

/**
* Sets the hosts allowlist.
*
* @param hostsAllowlist a list of hosts to be added to the allowlist
*/
public void setHostsAllowlist(final List<String> hostsAllowlist) {
checkNotNull(hostsAllowlist);
this.hostsAllowlist = hostsAllowlist;
}

/**
* Retrieves the HTTP timeout in seconds.
*
* @return the HTTP timeout in seconds
*/
public Long getHttpTimeoutSec() {
return httpTimeoutSec;
}

/**
* Sets the HTTP timeout in seconds.
*
* @param httpTimeoutSec the HTTP timeout to set in seconds
*/
public void setHttpTimeoutSec(final long httpTimeoutSec) {
this.httpTimeoutSec = httpTimeoutSec;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,33 @@
*/
package org.hyperledger.besu.ethereum.api.graphql;

/** Internal GraphQL Context */
/**
* Enum representing various context types for GraphQL.
*
* <p>These context types are used internally by GraphQL to manage different aspects of the system.
*/
public enum GraphQLContextType {
/** Represents blockchain queries context. */
BLOCKCHAIN_QUERIES,

/** Represents protocol schedule context. */
PROTOCOL_SCHEDULE,

/** Represents transaction pool context. */
TRANSACTION_POOL,

/** Represents mining coordinator context. */
MINING_COORDINATOR,

/** Represents synchronizer context. */
SYNCHRONIZER,

/** Represents is alive handler context. */
IS_ALIVE_HANDLER,

/** Represents chain ID context. */
CHAIN_ID,

/** Represents gas cap context. */
GAS_CAP
}
Loading
Loading