Merge branch 'main' into zkbesu

This commit is contained in:
Fabio Di Fabio
2024-04-09 18:34:48 +02:00
120 changed files with 552 additions and 187 deletions

View File

@@ -37,6 +37,7 @@
- Update Web3j dependencies [#6811](https://github.com/hyperledger/besu/pull/6811)
- Add `tx-pool-blob-price-bump` option to configure the price bump percentage required to replace blob transactions (by default 100%) [#6874](https://github.com/hyperledger/besu/pull/6874)
- Log detailed timing of block creation steps [#6880](https://github.com/hyperledger/besu/pull/6880)
- Expose transaction count by type metrics for the layered txpool [#6903](https://github.com/hyperledger/besu/pull/6903)
### Bug fixes
- Fix txpool dump/restore race condition [#6665](https://github.com/hyperledger/besu/pull/6665)

View File

@@ -22,15 +22,18 @@ public class JsonRpcTestCase {
private final JsonNode request;
private final JsonNode response;
private final int statusCode;
private final long waitTime;
@JsonCreator
public JsonRpcTestCase(
@JsonProperty("request") final JsonNode request,
@JsonProperty("response") final JsonNode response,
@JsonProperty("statusCode") final int statusCode) {
@JsonProperty("statusCode") final int statusCode,
@JsonProperty(value = "waitTime", defaultValue = "0") final long waitTime) {
this.request = request;
this.response = response;
this.statusCode = statusCode;
this.waitTime = waitTime;
}
public JsonNode getRequest() {
@@ -44,4 +47,8 @@ public class JsonRpcTestCase {
public int getStatusCode() {
return statusCode;
}
public long getWaitTime() {
return waitTime;
}
}

View File

@@ -93,6 +93,11 @@ abstract class AbstractJsonRpcTest {
.readTimeout(900, java.util.concurrent.TimeUnit.SECONDS)
.build();
}
if (testCase.getWaitTime() > 0L) {
waitForMillis(testCase.getWaitTime());
}
final Call testRequest =
client.newCall(
new Request.Builder()
@@ -112,6 +117,14 @@ abstract class AbstractJsonRpcTest {
.isEqualTo(expectedBody);
}
private static void waitForMillis(final long millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
protected void evaluateResponse(
final ObjectNode responseBody,
final Call testRequest,

View File

@@ -56,14 +56,6 @@ public class ExecutionEngineCancunBlockBuildingAcceptanceTest extends AbstractJs
final Call testRequest,
final JsonRpcTestCase testCase,
final URL url) {
if (url.toString().endsWith("10_cancun_build_on_genesis.json")) {
// if we just asked the node to build, give it some time to build
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
if (url.toString().endsWith("12_cancun_get_built_block.json")) {
// final ObjectNode rpcResponse = JsonUtil.objectNodeFromString(response.body().string());

View File

@@ -32,6 +32,8 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
public class BadCLIOptionsPluginTest extends AcceptanceTestBaseJunit5 {
private BesuNode node;
@@ -52,6 +54,7 @@ public class BadCLIOptionsPluginTest extends AcceptanceTestBaseJunit5 {
}
@Test
@DisabledOnOs(OS.MAC)
public void shouldNotRegister() {
final Path registrationFile = node.homeDirectory().resolve("plugins/badCLIOptions.init");
waitForFile(registrationFile);
@@ -59,6 +62,7 @@ public class BadCLIOptionsPluginTest extends AcceptanceTestBaseJunit5 {
}
@Test
@DisabledOnOs(OS.MAC)
public void shouldNotStart() {
// depend on the good PicoCLIOptions to tell us when it should be up
final Path registrationFile = node.homeDirectory().resolve("plugins/pluginLifecycle.started");

View File

@@ -24,6 +24,7 @@ import org.hyperledger.besu.tests.acceptance.dsl.pubsub.WebSocket;
import io.vertx.core.Vertx;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
public class NewPendingTransactionAcceptanceTest extends AcceptanceTestBase {
@@ -157,6 +158,7 @@ public class NewPendingTransactionAcceptanceTest extends AcceptanceTestBase {
}
@Test
@Disabled("This test is flaky and needs to be fixed")
public void everySubscriptionMustReceiveEveryPublishEvent() {
final Subscription minerSubscriptionOne = minerWebSocket.subscribe();
final Subscription minerSubscriptionTwo = minerWebSocket.subscribe();

View File

@@ -14,5 +14,6 @@
"remoteCount": 0
}
},
"statusCode": 200
"statusCode": 200,
"waitTime": 2000
}

View File

@@ -36,63 +36,92 @@ public interface DefaultCommandValues {
/** The constant MANDATORY_PATH_FORMAT_HELP. */
String MANDATORY_PATH_FORMAT_HELP = "<PATH>";
/** The constant MANDATORY_FILE_FORMAT_HELP. */
String MANDATORY_FILE_FORMAT_HELP = "<FILE>";
/** The constant MANDATORY_DIRECTORY_FORMAT_HELP. */
String MANDATORY_DIRECTORY_FORMAT_HELP = "<DIRECTORY>";
/** The constant BESU_HOME_PROPERTY_NAME. */
String BESU_HOME_PROPERTY_NAME = "besu.home";
/** The constant DEFAULT_DATA_DIR_PATH. */
String DEFAULT_DATA_DIR_PATH = "./build/data";
/** The constant MANDATORY_INTEGER_FORMAT_HELP. */
String MANDATORY_INTEGER_FORMAT_HELP = "<INTEGER>";
/** The constant MANDATORY_DOUBLE_FORMAT_HELP. */
String MANDATORY_DOUBLE_FORMAT_HELP = "<DOUBLE>";
/** The constant MANDATORY_LONG_FORMAT_HELP. */
String MANDATORY_LONG_FORMAT_HELP = "<LONG>";
/** The constant MANDATORY_MODE_FORMAT_HELP. */
String MANDATORY_MODE_FORMAT_HELP = "<MODE>";
/** The constant MANDATORY_NETWORK_FORMAT_HELP. */
String MANDATORY_NETWORK_FORMAT_HELP = "<NETWORK>";
/** The constant PROFILE_OPTION_NAME. */
String PROFILE_OPTION_NAME = "--profile";
/** The constant PROFILE_FORMAT_HELP. */
String PROFILE_FORMAT_HELP = "<PROFILE>";
/** The constant MANDATORY_NODE_ID_FORMAT_HELP. */
String MANDATORY_NODE_ID_FORMAT_HELP = "<NODEID>";
/** The constant PERMISSIONING_CONFIG_LOCATION. */
String PERMISSIONING_CONFIG_LOCATION = "permissions_config.toml";
/** The constant MANDATORY_HOST_FORMAT_HELP. */
String MANDATORY_HOST_FORMAT_HELP = "<HOST>";
/** The constant MANDATORY_PORT_FORMAT_HELP. */
String MANDATORY_PORT_FORMAT_HELP = "<PORT>";
/** The constant DEFAULT_NAT_METHOD. */
NatMethod DEFAULT_NAT_METHOD = NatMethod.AUTO;
/** The constant DEFAULT_JWT_ALGORITHM. */
JwtAlgorithm DEFAULT_JWT_ALGORITHM = JwtAlgorithm.RS256;
/** The constant SYNC_MIN_PEER_COUNT. */
int SYNC_MIN_PEER_COUNT = 5;
/** The constant DEFAULT_MAX_PEERS. */
int DEFAULT_MAX_PEERS = 25;
/** The constant DEFAULT_HTTP_MAX_CONNECTIONS. */
int DEFAULT_HTTP_MAX_CONNECTIONS = 80;
/** The constant DEFAULT_HTTP_MAX_BATCH_SIZE. */
int DEFAULT_HTTP_MAX_BATCH_SIZE = 1024;
/** The constant DEFAULT_MAX_REQUEST_CONTENT_LENGTH. */
long DEFAULT_MAX_REQUEST_CONTENT_LENGTH = 5 * 1024 * 1024; // 5MB
/** The constant DEFAULT_WS_MAX_CONNECTIONS. */
int DEFAULT_WS_MAX_CONNECTIONS = 80;
/** The constant DEFAULT_WS_MAX_FRAME_SIZE. */
int DEFAULT_WS_MAX_FRAME_SIZE = 1024 * 1024;
/** The constant DEFAULT_FRACTION_REMOTE_WIRE_CONNECTIONS_ALLOWED. */
float DEFAULT_FRACTION_REMOTE_WIRE_CONNECTIONS_ALLOWED =
RlpxConfiguration.DEFAULT_FRACTION_REMOTE_CONNECTIONS_ALLOWED;
/** The constant DEFAULT_KEY_VALUE_STORAGE_NAME. */
String DEFAULT_KEY_VALUE_STORAGE_NAME = "rocksdb";
/** The constant DEFAULT_SECURITY_MODULE. */
String DEFAULT_SECURITY_MODULE = "localfile";
/** The constant DEFAULT_KEYSTORE_TYPE. */
String DEFAULT_KEYSTORE_TYPE = "JKS";
/** The Default tls protocols. */
List<String> DEFAULT_TLS_PROTOCOLS = List.of("TLSv1.3", "TLSv1.2");

View File

@@ -44,6 +44,7 @@ import picocli.CommandLine;
/** The Transaction pool Cli stable options. */
public class TransactionPoolOptions implements CLIOptions<TransactionPoolConfiguration> {
private static final String TX_POOL_IMPLEMENTATION = "--tx-pool";
/** Use TX_POOL_NO_LOCAL_PRIORITY instead */
@Deprecated(forRemoval = true)
private static final String TX_POOL_DISABLE_LOCALS = "--tx-pool-disable-locals";

View File

@@ -103,6 +103,7 @@ public class DataStorageOptions implements CLIOptions<DataStorageConfiguration>
"Enables code storage using code hash instead of by account hash. (default: ${DEFAULT-VALUE})")
private boolean bonsaiCodeUsingCodeHashEnabled = DEFAULT_BONSAI_CODE_USING_CODE_HASH_ENABLED;
}
/**
* Create data storage options.
*

View File

@@ -35,6 +35,7 @@ public class LoggingLevelOption {
private static final Set<String> ACCEPTED_VALUES =
Set.of("OFF", "ERROR", "WARN", "INFO", "DEBUG", "TRACE", "ALL");
/** The Picocli CommandSpec. Visible for testing. Injected by Picocli framework at runtime. */
@Spec CommandSpec spec;

View File

@@ -30,8 +30,10 @@ public class ChainPruningOptions implements CLIOptions<ChainPrunerConfiguration>
private static final String CHAIN_PRUNING_BLOCKS_RETAINED_FLAG =
"--Xchain-pruning-blocks-retained";
private static final String CHAIN_PRUNING_FREQUENCY_FLAG = "--Xchain-pruning-frequency";
/** The constant DEFAULT_CHAIN_DATA_PRUNING_MIN_BLOCKS_RETAINED. */
public static final long DEFAULT_CHAIN_DATA_PRUNING_MIN_BLOCKS_RETAINED = 7200;
/** The constant DEFAULT_CHAIN_DATA_PRUNING_FREQUENCY. */
public static final int DEFAULT_CHAIN_DATA_PRUNING_FREQUENCY = 256;

View File

@@ -36,6 +36,7 @@ public class NetworkingOptions implements CLIOptions<NetworkingConfiguration> {
"--Xp2p-check-maintained-connections-frequency";
private final String DNS_DISCOVERY_SERVER_OVERRIDE_FLAG = "--Xp2p-dns-discovery-server";
private final String DISCOVERY_PROTOCOL_V5_ENABLED = "--Xv5-discovery-enabled";
/** The constant FILTER_ON_ENR_FORK_ID. */
public static final String FILTER_ON_ENR_FORK_ID = "--filter-on-enr-fork-id";

View File

@@ -42,6 +42,7 @@ public class OperatorSubCommand implements Runnable {
/** The constant COMMAND_NAME. */
public static final String COMMAND_NAME = "operator";
/** The constant GENERATE_BLOCKCHAIN_CONFIG_SUBCOMMAND_NAME. */
public static final String GENERATE_BLOCKCHAIN_CONFIG_SUBCOMMAND_NAME =
"generate-blockchain-config";

View File

@@ -36,11 +36,14 @@ public class CommandLineUtils {
/** The constant DEPENDENCY_WARNING_MSG. */
public static final String DEPENDENCY_WARNING_MSG =
"{} has been ignored because {} was not defined on the command line.";
/** The constant MULTI_DEPENDENCY_WARNING_MSG. */
public static final String MULTI_DEPENDENCY_WARNING_MSG =
"{} ignored because none of {} was defined.";
/** The constant DEPRECATION_WARNING_MSG. */
public static final String DEPRECATION_WARNING_MSG = "{} has been deprecated, use {} instead.";
/** The constant DEPRECATED_AND_USELESS_WARNING_MSG. */
public static final String DEPRECATED_AND_USELESS_WARNING_MSG =
"{} has been deprecated and is now useless, remove it.";

View File

@@ -57,6 +57,7 @@ public class BesuController implements java.io.Closeable {
/** The constant DATABASE_PATH. */
public static final String DATABASE_PATH = "database";
/** The constant CACHE_PATH. */
public static final String CACHE_PATH = "caches";

View File

@@ -129,56 +129,78 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
/** The Sync config. */
protected SynchronizerConfiguration syncConfig;
/** The Ethereum wire protocol configuration. */
protected EthProtocolConfiguration ethereumWireProtocolConfiguration;
/** The Transaction pool configuration. */
protected TransactionPoolConfiguration transactionPoolConfiguration;
/** The Network id. */
protected BigInteger networkId;
/** The Mining parameters. */
protected MiningParameters miningParameters;
/** The Metrics system. */
protected ObservableMetricsSystem metricsSystem;
/** The Privacy parameters. */
protected PrivacyParameters privacyParameters;
/** The Pki block creation configuration. */
protected Optional<PkiBlockCreationConfiguration> pkiBlockCreationConfiguration =
Optional.empty();
/** The Data directory. */
protected Path dataDirectory;
/** The Clock. */
protected Clock clock;
/** The Node key. */
protected NodeKey nodeKey;
/** The Is revert reason enabled. */
protected boolean isRevertReasonEnabled;
/** The Gas limit calculator. */
GasLimitCalculator gasLimitCalculator;
/** The Storage provider. */
protected StorageProvider storageProvider;
/** The Required blocks. */
protected Map<Long, Hash> requiredBlocks = Collections.emptyMap();
/** The Reorg logging threshold. */
protected long reorgLoggingThreshold;
/** The Data storage configuration. */
protected DataStorageConfiguration dataStorageConfiguration =
DataStorageConfiguration.DEFAULT_CONFIG;
/** The Message permissioning providers. */
protected List<NodeMessagePermissioningProvider> messagePermissioningProviders =
Collections.emptyList();
/** The Evm configuration. */
protected EvmConfiguration evmConfiguration;
/** The Max peers. */
protected int maxPeers;
/** Manages a cache of bad blocks globally */
protected final BadBlockManager badBlockManager = new BadBlockManager();
private int maxRemotelyInitiatedPeers;
/** The Chain pruner configuration. */
protected ChainPrunerConfiguration chainPrunerConfiguration = ChainPrunerConfiguration.DEFAULT;
private NetworkingConfiguration networkingConfiguration;
private Boolean randomPeerPriority;
/** the Dagger configured context that can provide dependencies */
protected Optional<BesuComponent> besuComponent = Optional.empty();
@@ -1022,8 +1044,9 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
yield new ForestWorldStateArchive(
worldStateStorageCoordinator, preimageStorage, evmConfiguration);
}
default -> throw new IllegalStateException(
"Unexpected value: " + dataStorageConfiguration.getDataStorageFormat());
default ->
throw new IllegalStateException(
"Unexpected value: " + dataStorageConfiguration.getDataStorageFormat());
};
}

View File

@@ -747,6 +747,7 @@ public abstract class CommandTestAbstract {
assertThat(stringArgumentCaptor.getAllValues().get(2)).isEqualTo(mainOption);
}
/**
* Check logger calls
*

View File

@@ -188,7 +188,7 @@ allprojects {
target 'src/**/*.java'
targetExclude '**/src/reference-test/**', '**/src/main/generated/**', '**/src/test/generated/**', '**/src/jmh/generated/**'
removeUnusedImports()
googleJavaFormat('1.15.0')
googleJavaFormat('1.22.0')
importOrder 'org.hyperledger', 'java', ''
trimTrailingWhitespace()
endWithNewline()

View File

@@ -33,12 +33,16 @@ public class BftFork implements Fork {
/** The constant FORK_BLOCK_KEY. */
public static final String FORK_BLOCK_KEY = "block";
/** The constant VALIDATORS_KEY. */
public static final String VALIDATORS_KEY = "validators";
/** The constant BLOCK_PERIOD_SECONDS_KEY. */
public static final String BLOCK_PERIOD_SECONDS_KEY = "blockperiodseconds";
/** The constant BLOCK_REWARD_KEY. */
public static final String BLOCK_REWARD_KEY = "blockreward";
/** The constant MINING_BENEFICIARY_KEY. */
public static final String MINING_BENEFICIARY_KEY = "miningbeneficiary";

View File

@@ -26,8 +26,10 @@ public class JsonQbftConfigOptions extends JsonBftConfigOptions implements QbftC
/** The constant DEFAULT. */
public static final JsonQbftConfigOptions DEFAULT =
new JsonQbftConfigOptions(JsonUtil.createEmptyObjectNode());
/** The constant VALIDATOR_CONTRACT_ADDRESS. */
public static final String VALIDATOR_CONTRACT_ADDRESS = "validatorcontractaddress";
/** The constant START_BLOCK. */
public static final String START_BLOCK = "startblock";

View File

@@ -34,6 +34,7 @@ public class QbftFork extends BftFork {
/** The constant VALIDATOR_SELECTION_MODE_KEY. */
public static final String VALIDATOR_SELECTION_MODE_KEY = "validatorselectionmode";
/** The constant VALIDATOR_CONTRACT_ADDRESS_KEY. */
public static final String VALIDATOR_CONTRACT_ADDRESS_KEY = "validatorcontractaddress";

View File

@@ -35,6 +35,7 @@ public class CliqueBlockInterface implements BlockInterface {
/** The constant ADD_NONCE. */
public static final long ADD_NONCE = 0xFFFFFFFFFFFFFFFFL;
/** The constant DROP_NONCE. */
public static final long DROP_NONCE = 0x0L;

View File

@@ -39,6 +39,7 @@ import org.slf4j.LoggerFactory;
*/
public class CliqueExtraData implements ParsedExtraData {
private static final Logger LOG = LoggerFactory.getLogger(CliqueExtraData.class);
/** The constant EXTRA_VANITY_LENGTH. */
public static final int EXTRA_VANITY_LENGTH = 32;

View File

@@ -29,6 +29,7 @@ public class Vote {
/** The constant ADD_BYTE_VALUE. */
public static final byte ADD_BYTE_VALUE = (byte) 0xFF;
/** The constant DROP_BYTE_VALUE. */
public static final byte DROP_BYTE_VALUE = (byte) 0x0L;

View File

@@ -52,16 +52,21 @@ import org.apache.tuweni.bytes.Bytes;
public class BftBlockCreatorFactory<T extends BftConfigOptions> {
/** The Forks schedule. */
protected final ForksSchedule<T> forksSchedule;
/** The Mining parameters */
protected final MiningParameters miningParameters;
private final TransactionPool transactionPool;
/** The Protocol context. */
protected final ProtocolContext protocolContext;
/** The Protocol schedule. */
protected final ProtocolSchedule protocolSchedule;
/** The Bft extra data codec. */
protected final BftExtraDataCodec bftExtraDataCodec;
/** The scheduler for asynchronous block creation tasks */
protected final EthScheduler ethScheduler;

View File

@@ -56,6 +56,7 @@ public class BftMiningCoordinator implements MiningCoordinator, BlockAddedObserv
private final BftEventHandler eventHandler;
private final BftProcessor bftProcessor;
private final BftBlockCreatorFactory<?> blockCreatorFactory;
/** The Blockchain. */
protected final Blockchain blockchain;

View File

@@ -18,10 +18,13 @@ package org.hyperledger.besu.consensus.ibft.messagedata;
public class IbftV2 {
/** The constant PROPOSAL. */
public static final int PROPOSAL = 0;
/** The constant PREPARE. */
public static final int PREPARE = 1;
/** The constant COMMIT. */
public static final int COMMIT = 2;
/** The constant ROUND_CHANGE. */
public static final int ROUND_CHANGE = 3;

View File

@@ -23,6 +23,7 @@ public class IbftSubProtocol implements SubProtocol {
/** The constant NAME. */
public static String NAME = "IBF";
/** The constant IBFV1. */
public static final Capability IBFV1 = Capability.create(NAME, 1);

View File

@@ -57,6 +57,7 @@ public class IbftRound {
private final Subscribers<MinedBlockObserver> observers;
private final RoundState roundState;
private final BlockCreator blockCreator;
/** The protocol context. */
protected final ProtocolContext protocolContext;

View File

@@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory;
/** The Post merge context. */
public class PostMergeContext implements MergeContext {
private static final Logger LOG = LoggerFactory.getLogger(PostMergeContext.class);
/** The Max blocks in progress. */
static final int MAX_BLOCKS_IN_PROGRESS = 12;

View File

@@ -28,6 +28,7 @@ import java.util.Optional;
public class TransitionContext implements MergeContext {
/** The Pre merge context. */
final ConsensusContext preMergeContext;
/** The Post merge context. */
final MergeContext postMergeContext;

View File

@@ -69,6 +69,7 @@ import org.slf4j.LoggerFactory;
/** The Merge coordinator. */
public class MergeCoordinator implements MergeMiningCoordinator, BadChainListener {
private static final Logger LOG = LoggerFactory.getLogger(MergeCoordinator.class);
/**
* On PoS you do not need to compete with other nodes for block production, since you have an
* allocated slot for that, so in this case make sense to always try to fill the block, if there
@@ -79,18 +80,25 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
private static final double TRY_FILL_BLOCK = 1.0;
private static final long DEFAULT_TARGET_GAS_LIMIT = 30000000L;
/** The Mining parameters. */
protected final MiningParameters miningParameters;
/** The Merge block creator factory. */
protected final MergeBlockCreatorFactory mergeBlockCreatorFactory;
/** The Merge context. */
protected final MergeContext mergeContext;
/** The Protocol context. */
protected final ProtocolContext protocolContext;
/** The Block builder executor. */
protected final EthScheduler ethScheduler;
/** The Backward sync context. */
protected final BackwardSyncContext backwardSyncContext;
/** The Protocol schedule. */
protected final ProtocolSchedule protocolSchedule;
@@ -866,6 +874,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
private static class BlockCreationTask {
/** The Block creator. */
final MergeBlockCreator blockCreator;
/** The Cancelled. */
final AtomicBoolean cancelled;

View File

@@ -18,10 +18,13 @@ package org.hyperledger.besu.consensus.qbft.messagedata;
public class QbftV1 {
/** The constant PROPOSAL. */
public static final int PROPOSAL = 0x12;
/** The constant PREPARE. */
public static final int PREPARE = 0x13;
/** The constant COMMIT. */
public static final int COMMIT = 0x14;
/** The constant ROUND_CHANGE. */
public static final int ROUND_CHANGE = 0x15;

View File

@@ -23,6 +23,7 @@ public class Istanbul100SubProtocol implements SubProtocol {
/** The constant NAME. */
public static String NAME = "istanbul";
/** The constant ISTANBUL_100. */
public static final Capability ISTANBUL_100 = Capability.create(NAME, 100);

View File

@@ -60,18 +60,23 @@ public class QbftRound {
private static final Logger LOG = LoggerFactory.getLogger(QbftRound.class);
private final Subscribers<MinedBlockObserver> observers;
/** The Round state. */
protected final RoundState roundState;
/** The Block creator. */
protected final BlockCreator blockCreator;
/** The Protocol context. */
protected final ProtocolContext protocolContext;
/** The Protocol schedule. */
protected final ProtocolSchedule protocolSchedule;
private final NodeKey nodeKey;
private final MessageFactory messageFactory; // used only to create stored local msgs
private final QbftMessageTransmitter transmitter;
/** The Bft extra data codec. */
protected final BftExtraDataCodec bftExtraDataCodec;

View File

@@ -39,6 +39,7 @@ import org.web3j.abi.datatypes.Type;
public class ValidatorContractController {
/** The constant GET_VALIDATORS. */
public static final String GET_VALIDATORS = "getValidators";
/** The constant CONTRACT_ERROR_MSG. */
public static final String CONTRACT_ERROR_MSG = "Failed validator smart contract call";

View File

@@ -50,11 +50,13 @@ public abstract class AbstractSECP256 implements SignatureAlgorithm {
/** The Curve. */
protected final ECDomainParameters curve;
/** The Half curve order. */
protected final BigInteger halfCurveOrder;
/** The Key pair generator. */
protected final KeyPairGenerator keyPairGenerator;
/** The Curve order. */
protected final BigInteger curveOrder;

View File

@@ -30,10 +30,13 @@ public class MessageDigestFactory {
/** Keccak-256 */
public static final String KECCAK256_ALG = "KECCAK-256";
/** SHA-256 */
public static final String SHA256_ALG = "SHA-256";
/** RipeMD-160 */
public static final String RIPEMD160_ALG = "RIPEMD160";
/** Blake2b F Function */
public static final String BLAKE2BF_ALG = "BLAKE2BF";

View File

@@ -26,6 +26,7 @@ public class SECPPrivateKey implements java.security.PrivateKey {
/** Encoded Bytes */
private final Bytes32 encoded;
/** Algorithm */
private final String algorithm;

View File

@@ -34,6 +34,7 @@ public class SECPPublicKey implements java.security.PublicKey {
/** Encoded Bytes */
private final Bytes encoded;
/** Algorithm */
private final String algorithm;

View File

@@ -31,6 +31,7 @@ public class SECPSignature {
/** The constant BYTES_REQUIRED. */
public static final int BYTES_REQUIRED = 65;
/**
* The recovery id to reconstruct the public key used to create the signature.
*

View File

@@ -32,8 +32,10 @@ public abstract class AbstractFqp<T extends AbstractFqp> implements FieldElement
/** The Degree. */
protected final int degree;
/** The Modulus coefficients. */
protected final Fq[] modulusCoefficients;
/** The Coefficients. */
protected final Fq[] coefficients;

View File

@@ -43,40 +43,58 @@ public class Address extends DelegatingBytes {
/** The constant SHA256. */
public static final Address SHA256 = Address.precompiled(0x02);
/** The constant RIPEMD160. */
public static final Address RIPEMD160 = Address.precompiled(0x03);
/** The constant ID. */
public static final Address ID = Address.precompiled(0x04);
/** The constant MODEXP. */
public static final Address MODEXP = Address.precompiled(0x05);
/** The constant ALTBN128_ADD. */
public static final Address ALTBN128_ADD = Address.precompiled(0x06);
/** The constant ALTBN128_MUL. */
public static final Address ALTBN128_MUL = Address.precompiled(0x07);
/** The constant ALTBN128_PAIRING. */
public static final Address ALTBN128_PAIRING = Address.precompiled(0x08);
/** The constant BLAKE2B_F_COMPRESSION. */
public static final Address BLAKE2B_F_COMPRESSION = Address.precompiled(0x09);
/** The constant KZG_POINT_EVAL aka POINT_EVALUATION_PRECOMPILE_ADDRESS. */
public static final Address KZG_POINT_EVAL = Address.precompiled(0xA);
/** The constant BLS12_G1ADD. */
public static final Address BLS12_G1ADD = Address.precompiled(0xB);
/** The constant BLS12_G1MUL. */
public static final Address BLS12_G1MUL = Address.precompiled(0xC);
/** The constant BLS12_G1MULTIEXP. */
public static final Address BLS12_G1MULTIEXP = Address.precompiled(0xD);
/** The constant BLS12_G2ADD. */
public static final Address BLS12_G2ADD = Address.precompiled(0xE);
/** The constant BLS12_G2MUL. */
public static final Address BLS12_G2MUL = Address.precompiled(0xF);
/** The constant BLS12_G2MULTIEXP. */
public static final Address BLS12_G2MULTIEXP = Address.precompiled(0x10);
/** The constant BLS12_PAIRING. */
public static final Address BLS12_PAIRING = Address.precompiled(0x11);
/** The constant BLS12_MAP_FP_TO_G1. */
public static final Address BLS12_MAP_FP_TO_G1 = Address.precompiled(0x12);
/** The constant BLS12_MAP_FP2_TO_G2. */
public static final Address BLS12_MAP_FP2_TO_G2 = Address.precompiled(0x13);
/** The constant ZERO. */
public static final Address ZERO = Address.fromHexString("0x0");

View File

@@ -195,8 +195,10 @@ public final class Wei extends BaseUInt256Value<Wei> implements Quantity {
/** The Pow. */
final int pow;
/** The Divisor. */
final double divisor;
/** The Decimals. */
final int decimals;

View File

@@ -22,12 +22,16 @@ public class PrivacyGroup implements Serializable {
/** Private Group Id */
private String privacyGroupId;
/** Name */
private String name;
/** Description */
private String description;
/** Type */
private Type type;
/** Members */
private List<String> members;

View File

@@ -49,7 +49,7 @@ public class BlockCreationTiming {
@Override
public String toString() {
final var sb = new StringBuilder("Started at " + startedAt + ", ");
final var sb = new StringBuilder("started at " + startedAt + ", ");
var prevDuration = Duration.ZERO;
for (final var entry : timing.entrySet()) {

View File

@@ -168,7 +168,7 @@ public class BlockMiner<M extends AbstractBlockCreator> implements Runnable {
}
private void logProducedBlock(final Block block, final BlockCreationTiming blockCreationTiming) {
String log =
LOG.info(
String.format(
"Produced #%,d / %d tx / %d om / %,d (%01.1f%%) gas / (%s) in %01.3fs",
block.getHeader().getNumber(),
@@ -177,13 +177,9 @@ public class BlockMiner<M extends AbstractBlockCreator> implements Runnable {
block.getHeader().getGasUsed(),
(block.getHeader().getGasUsed() * 100.0) / block.getHeader().getGasLimit(),
block.getHash(),
blockCreationTiming.end("log").getSeconds() / 1000.0);
blockCreationTiming.end("log").toMillis() / 1000.0));
if (LOG.isDebugEnabled()) {
log = log + ", timing [" + blockCreationTiming + "]";
}
LOG.info(log);
LOG.debug("Timing #{} / {}", block.getHeader().getNumber(), blockCreationTiming);
}
public void cancel() {

View File

@@ -39,6 +39,7 @@ public class TransactionSelectionResults {
private final Map<TransactionType, List<Transaction>> transactionsByType =
new EnumMap<>(TransactionType.class);
private final List<TransactionReceipt> receipts = Lists.newArrayList();
/**
* Access to this field needs to be guarded, since it is possible to read it while another
* processing thread is writing, when the selection time is over.

View File

@@ -26,6 +26,7 @@ public class BlockBody implements org.hyperledger.besu.plugin.data.BlockBody {
private static final BlockBody EMPTY =
new BlockBody(Collections.emptyList(), Collections.emptyList());
/**
* Adding a new field with a corresponding root hash in the block header will require a change in
* {@link org.hyperledger.besu.ethereum.eth.manager.task.GetBodiesFromPeerTask.BodyIdentifier}

View File

@@ -703,40 +703,43 @@ public class Transaction
final Bytes preimage =
switch (transactionType) {
case FRONTIER -> frontierPreimage(nonce, gasPrice, gasLimit, to, value, payload, chainId);
case EIP1559 -> eip1559Preimage(
nonce,
maxPriorityFeePerGas,
maxFeePerGas,
gasLimit,
to,
value,
payload,
chainId,
accessList);
case BLOB -> blobPreimage(
nonce,
maxPriorityFeePerGas,
maxFeePerGas,
maxFeePerBlobGas,
gasLimit,
to,
value,
payload,
chainId,
accessList,
versionedHashes);
case ACCESS_LIST -> accessListPreimage(
nonce,
gasPrice,
gasLimit,
to,
value,
payload,
accessList.orElseThrow(
() ->
new IllegalStateException(
"Developer error: the transaction should be guaranteed to have an access list here")),
chainId);
case EIP1559 ->
eip1559Preimage(
nonce,
maxPriorityFeePerGas,
maxFeePerGas,
gasLimit,
to,
value,
payload,
chainId,
accessList);
case BLOB ->
blobPreimage(
nonce,
maxPriorityFeePerGas,
maxFeePerGas,
maxFeePerBlobGas,
gasLimit,
to,
value,
payload,
chainId,
accessList,
versionedHashes);
case ACCESS_LIST ->
accessListPreimage(
nonce,
gasPrice,
gasLimit,
to,
value,
payload,
accessList.orElseThrow(
() ->
new IllegalStateException(
"Developer error: the transaction should be guaranteed to have an access list here")),
chainId);
};
return keccak256(preimage);
}

View File

@@ -43,20 +43,22 @@ public class BlockHeaderValidator {
final HeaderValidationMode mode) {
return switch (mode) {
case NONE -> true;
case LIGHT_DETACHED_ONLY -> applyRules(
header,
parent,
protocolContext,
rule -> rule.includeInLightValidation() && rule.isDetachedSupported());
case LIGHT_SKIP_DETACHED -> applyRules(
header,
parent,
protocolContext,
rule -> rule.includeInLightValidation() && !rule.isDetachedSupported());
case LIGHT_DETACHED_ONLY ->
applyRules(
header,
parent,
protocolContext,
rule -> rule.includeInLightValidation() && rule.isDetachedSupported());
case LIGHT_SKIP_DETACHED ->
applyRules(
header,
parent,
protocolContext,
rule -> rule.includeInLightValidation() && !rule.isDetachedSupported());
case LIGHT -> applyRules(header, parent, protocolContext, Rule::includeInLightValidation);
case DETACHED_ONLY -> applyRules(header, parent, protocolContext, Rule::isDetachedSupported);
case SKIP_DETACHED -> applyRules(
header, parent, protocolContext, rule -> !rule.isDetachedSupported());
case SKIP_DETACHED ->
applyRules(header, parent, protocolContext, rule -> !rule.isDetachedSupported());
case FULL -> applyRules(header, parent, protocolContext, rule -> true);
};
}

View File

@@ -430,15 +430,18 @@ public class ProtocolScheduleBuilder {
final Function<ProtocolSpecBuilder, ProtocolSpecBuilder> modifier) {
switch (milestoneType) {
case BLOCK_NUMBER -> protocolSchedule.putBlockNumberMilestone(
blockNumberOrTimestamp, getProtocolSpec(protocolSchedule, definition, modifier));
case TIMESTAMP -> protocolSchedule.putTimestampMilestone(
blockNumberOrTimestamp, getProtocolSpec(protocolSchedule, definition, modifier));
default -> throw new IllegalStateException(
"Unexpected milestoneType: "
+ milestoneType
+ " for milestone: "
+ blockNumberOrTimestamp);
case BLOCK_NUMBER ->
protocolSchedule.putBlockNumberMilestone(
blockNumberOrTimestamp, getProtocolSpec(protocolSchedule, definition, modifier));
case TIMESTAMP ->
protocolSchedule.putTimestampMilestone(
blockNumberOrTimestamp, getProtocolSpec(protocolSchedule, definition, modifier));
default ->
throw new IllegalStateException(
"Unexpected milestoneType: "
+ milestoneType
+ " for milestone: "
+ blockNumberOrTimestamp);
}
}

View File

@@ -81,6 +81,7 @@ public class BonsaiWorldStateProvider extends DiffBasedWorldStateProvider {
private BonsaiWorldStateKeyValueStorage getWorldStateKeyValueStorage() {
return (BonsaiWorldStateKeyValueStorage) worldStateKeyValueStorage;
}
/**
* Prepares the state healing process for a given address and location. It prepares the state
* healing, including retrieving data from storage, identifying invalid slots or nodes, removing

View File

@@ -216,6 +216,7 @@ public class ForestMutableWorldState implements MutableWorldState {
return Optional.ofNullable(newAccountKeyPreimages.get(trieKey))
.or(() -> preimageStorage.getAccountTrieKeyPreimage(trieKey));
}
// An immutable class that represents an individual account as stored in
// the world state's underlying merkle patricia trie.
protected class WorldStateAccount implements Account {

View File

@@ -67,6 +67,7 @@ public class EthProtocolVersion {
EthPV63.NODE_DATA,
EthPV63.GET_RECEIPTS,
EthPV63.RECEIPTS);
/**
* eth/65 (EIP-2464, January 2020)
*

View File

@@ -50,6 +50,7 @@ public class TransactionAnnouncementDecoder {
return TransactionAnnouncementDecoder::decodeForEth66;
}
}
/**
* Decode the list of transactions in the NewPooledTransactionHashesMessage
*

View File

@@ -30,6 +30,7 @@ public final class StorageExceptionManager {
private static final long ERROR_THRESHOLD = 1000;
private static long retryableErrorCounter;
/**
* Determines if an operation can be retried based on the error received. This method checks if
* the cause of the StorageException is a RocksDBException. If it is, it retrieves the status code

View File

@@ -87,8 +87,8 @@ public class ImportBlocksStep implements Consumer<List<BlockWithReceipts>> {
if (accumulatedTime > PRINT_DELAY) {
final long blocksPercent = getBlocksPercent(lastBlock, pivotHeader.getNumber());
LOG.info(
"Block import progress: {} of {} ({}%)",
lastBlock, pivotHeader.getNumber(), blocksPercent);
"Block import progress: {} of {} ({}%), Peer count: {}",
lastBlock, pivotHeader.getNumber(), blocksPercent, peerCount);
LOG.debug(
"Completed importing chain segment {} to {} ({} blocks in {}ms), Peer count: {}",
logStartBlock.getAsLong(),

View File

@@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.ethereum.eth.transactions;
import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import org.hyperledger.besu.metrics.BesuMetricCategory;
import org.hyperledger.besu.metrics.ReplaceableDoubleSupplier;
@@ -27,6 +28,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.function.DoubleSupplier;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,12 +45,15 @@ public class TransactionPoolMetrics {
private final LabelledMetric<Counter> rejectedCounter;
private final LabelledGauge spaceUsed;
private final LabelledGauge transactionCount;
private final LabelledGauge transactionCountByType;
private final LabelledGauge uniqueSenderCount;
private final LabelledMetric<Counter> expiredMessagesCounter;
private final Map<String, RunnableCounter> expiredMessagesRunnableCounters = new HashMap<>();
private final LabelledMetric<Counter> alreadySeenTransactionsCounter;
private final Map<String, ReplaceableDoubleSupplier> spaceUsedSuppliers = new HashMap<>();
private final Map<String, ReplaceableDoubleSupplier> transactionCountSuppliers = new HashMap<>();
private final Map<Pair<String, TransactionType>, ReplaceableDoubleSupplier>
transactionCountByTypeSuppliers = new HashMap<>();
private final Map<String, ReplaceableDoubleSupplier> uniqueSendersSuppliers = new HashMap<>();
public TransactionPoolMetrics(final MetricsSystem metricsSystem) {
@@ -97,6 +102,14 @@ public class TransactionPoolMetrics {
"The number of transactions currently present in the layer",
"layer");
transactionCountByType =
metricsSystem.createLabelledGauge(
BesuMetricCategory.TRANSACTION_POOL,
"number_of_transactions_by_type",
"The number of transactions, of a specified type, currently present in the layer",
"layer",
"type");
uniqueSenderCount =
metricsSystem.createLabelledGauge(
BesuMetricCategory.TRANSACTION_POOL,
@@ -136,6 +149,20 @@ public class TransactionPoolMetrics {
});
}
public void initTransactionCountByType(
final DoubleSupplier spaceUsedSupplier, final String layer, final TransactionType type) {
transactionCountByTypeSuppliers.compute(
Pair.of(layer, type),
(unused, existingSupplier) -> {
if (existingSupplier == null) {
final var newSupplier = new ReplaceableDoubleSupplier(spaceUsedSupplier);
transactionCountByType.labels(newSupplier, layer, type.name());
return newSupplier;
}
return existingSupplier.replaceDoubleSupplier(spaceUsedSupplier);
});
}
public void initTransactionCount(
final DoubleSupplier transactionCountSupplier, final String layer) {
transactionCountSuppliers.compute(

View File

@@ -26,6 +26,7 @@ import static org.hyperledger.besu.ethereum.eth.transactions.layered.Transaction
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.BlobCache;
@@ -39,6 +40,7 @@ import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
import org.hyperledger.besu.util.Subscribers;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -74,7 +76,7 @@ public abstract class AbstractTransactionsLayer implements TransactionsLayer {
private OptionalLong nextLayerOnAddedListenerId = OptionalLong.empty();
private OptionalLong nextLayerOnDroppedListenerId = OptionalLong.empty();
protected long spaceUsed = 0;
protected final int[] txCountByType = new int[TransactionType.values().length];
private final BlobCache blobCache;
protected AbstractTransactionsLayer(
@@ -91,6 +93,11 @@ public abstract class AbstractTransactionsLayer implements TransactionsLayer {
metrics.initSpaceUsed(this::getLayerSpaceUsed, name());
metrics.initTransactionCount(pendingTransactions::size, name());
metrics.initUniqueSenderCount(txsBySender::size, name());
Arrays.stream(TransactionType.values())
.forEach(
type ->
metrics.initTransactionCountByType(
() -> txCountByType[type.ordinal()], name(), type));
this.blobCache = blobCache;
}
@@ -101,6 +108,7 @@ public abstract class AbstractTransactionsLayer implements TransactionsLayer {
pendingTransactions.clear();
txsBySender.clear();
spaceUsed = 0;
Arrays.fill(txCountByType, 0);
nextLayer.reset();
}
@@ -286,7 +294,7 @@ public abstract class AbstractTransactionsLayer implements TransactionsLayer {
pendingTransactions.put(addedTx.getHash(), addedTx);
final var senderTxs = txsBySender.computeIfAbsent(addedTx.getSender(), s -> new TreeMap<>());
senderTxs.put(addedTx.getNonce(), addedTx);
increaseSpaceUsed(addedTx);
increaseCounters(addedTx);
metrics.incrementAdded(addedTx, name());
internalAdd(senderTxs, addedTx);
}
@@ -332,7 +340,7 @@ public abstract class AbstractTransactionsLayer implements TransactionsLayer {
protected void replaced(final PendingTransaction replacedTx) {
pendingTransactions.remove(replacedTx.getHash());
decreaseSpaceUsed(replacedTx);
decreaseCounters(replacedTx);
metrics.incrementRemoved(replacedTx, REPLACED.label(), name());
internalReplaced(replacedTx);
notifyTransactionDropped(replacedTx);
@@ -368,7 +376,7 @@ public abstract class AbstractTransactionsLayer implements TransactionsLayer {
final PendingTransaction removedTx = pendingTransactions.remove(transaction.getHash());
if (removedTx != null) {
decreaseSpaceUsed(removedTx);
decreaseCounters(removedTx);
metrics.incrementRemoved(removedTx, removalReason.label(), name());
internalRemove(senderTxs, removedTx, removalReason);
}
@@ -381,7 +389,7 @@ public abstract class AbstractTransactionsLayer implements TransactionsLayer {
final RemovalReason reason) {
final PendingTransaction removedTx = pendingTransactions.remove(evictedTx.getHash());
if (removedTx != null) {
decreaseSpaceUsed(evictedTx);
decreaseCounters(evictedTx);
metrics.incrementRemoved(evictedTx, reason.label(), name());
internalEvict(senderTxs, removedTx);
}
@@ -467,12 +475,14 @@ public abstract class AbstractTransactionsLayer implements TransactionsLayer {
protected abstract PendingTransaction getEvictable();
protected void increaseSpaceUsed(final PendingTransaction pendingTransaction) {
protected void increaseCounters(final PendingTransaction pendingTransaction) {
spaceUsed += pendingTransaction.memorySize();
++txCountByType[pendingTransaction.getTransaction().getType().ordinal()];
}
protected void decreaseSpaceUsed(final PendingTransaction pendingTransaction) {
protected void decreaseCounters(final PendingTransaction pendingTransaction) {
spaceUsed -= pendingTransaction.memorySize();
--txCountByType[pendingTransaction.getTransaction().getType().ordinal()];
}
protected abstract long cacheFreeSpace();

View File

@@ -517,6 +517,7 @@ public abstract class AbstractPendingTransactionsSorter implements PendingTransa
return sb.toString();
}
}
/**
* @param transaction to restore blobs onto
* @return an optional copy of the supplied transaction, but with the BlobsWithCommitments

View File

@@ -714,6 +714,7 @@ public class PeerDiscoveryController {
private class PeerInteractionState implements Predicate<Packet> {
private static final int MAX_RETRIES = 5;
/**
* The action that led to the peer being in this state (e.g. sending a PING or NEIGHBORS
* message), in case it needs to be retried.
@@ -721,12 +722,15 @@ public class PeerDiscoveryController {
private final Consumer<PeerInteractionState> action;
private final Bytes peerId;
/** The expected type of the message that will transition the peer out of this state. */
private final PacketType expectedType;
private final Counter retryCounter;
/** A custom filter to accept transitions out of this state. */
private Predicate<Packet> filter;
/** Timers associated with this entry. */
private OptionalLong timerId = OptionalLong.empty();

View File

@@ -88,6 +88,7 @@ public interface P2PNetwork extends Closeable {
void subscribeConnect(final ConnectCallback callback);
void subscribeConnectRequest(final ShouldConnectCallback callback);
/**
* Subscribe a {@link Consumer} to all incoming new Peer disconnect events.
*

View File

@@ -67,6 +67,7 @@ public interface ProtocolManager extends AutoCloseable {
* @return true, if the ProtocolManager wants to connect to the peer, false otherwise
*/
boolean shouldConnect(Peer peer, final boolean incoming);
/**
* Handles peer disconnects.
*

View File

@@ -80,6 +80,7 @@ public interface RLPOutput {
default void writeUInt64Scalar(final UInt64Value<?> v) {
writeBytes(v.toBytes().trimLeadingZeros());
}
/**
* Writes a scalar (encoded with no leading zeroes).
*

View File

@@ -75,6 +75,7 @@ public interface MerkleTrie<K, V> {
* @param value The value to associate the key with.
*/
void putPath(K path, V value);
/**
* Updates the value mapped to the specified key, creating the mapping if one does not already
* exist.

View File

@@ -230,73 +230,77 @@ public class EVM {
case 0x56 -> JumpOperation.staticOperation(frame);
case 0x57 -> JumpiOperation.staticOperation(frame);
case 0x5b -> JumpDestOperation.JUMPDEST_SUCCESS;
case 0x5f -> enableShanghai
? Push0Operation.staticOperation(frame)
: InvalidOperation.INVALID_RESULT;
case 0x5f ->
enableShanghai
? Push0Operation.staticOperation(frame)
: InvalidOperation.INVALID_RESULT;
case 0x60, // PUSH1-32
0x61,
0x62,
0x63,
0x64,
0x65,
0x66,
0x67,
0x68,
0x69,
0x6a,
0x6b,
0x6c,
0x6d,
0x6e,
0x6f,
0x70,
0x71,
0x72,
0x73,
0x74,
0x75,
0x76,
0x77,
0x78,
0x79,
0x7a,
0x7b,
0x7c,
0x7d,
0x7e,
0x7f -> PushOperation.staticOperation(frame, code, pc, opcode - PUSH_BASE);
0x61,
0x62,
0x63,
0x64,
0x65,
0x66,
0x67,
0x68,
0x69,
0x6a,
0x6b,
0x6c,
0x6d,
0x6e,
0x6f,
0x70,
0x71,
0x72,
0x73,
0x74,
0x75,
0x76,
0x77,
0x78,
0x79,
0x7a,
0x7b,
0x7c,
0x7d,
0x7e,
0x7f ->
PushOperation.staticOperation(frame, code, pc, opcode - PUSH_BASE);
case 0x80, // DUP1-16
0x81,
0x82,
0x83,
0x84,
0x85,
0x86,
0x87,
0x88,
0x89,
0x8a,
0x8b,
0x8c,
0x8d,
0x8e,
0x8f -> DupOperation.staticOperation(frame, opcode - DupOperation.DUP_BASE);
0x81,
0x82,
0x83,
0x84,
0x85,
0x86,
0x87,
0x88,
0x89,
0x8a,
0x8b,
0x8c,
0x8d,
0x8e,
0x8f ->
DupOperation.staticOperation(frame, opcode - DupOperation.DUP_BASE);
case 0x90, // SWAP1-16
0x91,
0x92,
0x93,
0x94,
0x95,
0x96,
0x97,
0x98,
0x99,
0x9a,
0x9b,
0x9c,
0x9d,
0x9e,
0x9f -> SwapOperation.staticOperation(frame, opcode - SWAP_BASE);
0x91,
0x92,
0x93,
0x94,
0x95,
0x96,
0x97,
0x98,
0x99,
0x9a,
0x9b,
0x9c,
0x9d,
0x9e,
0x9f ->
SwapOperation.staticOperation(frame, opcode - SWAP_BASE);
default -> { // unoptimized operations
frame.setCurrentOperation(currentOperation);
yield currentOperation.execute(frame, this);

View File

@@ -65,11 +65,13 @@ public enum EvmSpecVersion {
/** The Spec finalized. */
final boolean specFinalized;
/** The Max eof version. */
final int maxEofVersion;
/** Public name matching execution-spec-tests name */
final String name;
/** A brief description of the state of the fork */
final String description;

View File

@@ -137,6 +137,7 @@ public class MainnetEVMs {
/** The constant SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT. */
public static final int SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT = 0x6000;
/** The constant SHANGHAI_INIT_CODE_SIZE_LIMIT. */
public static final int SHANGHAI_INIT_CODE_SIZE_LIMIT = 2 * SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT;
@@ -870,6 +871,7 @@ public class MainnetEVMs {
public static EVM cancun(final EvmConfiguration evmConfiguration) {
return cancun(DEV_NET_CHAIN_ID, evmConfiguration);
}
/**
* Cancun evm.
*
@@ -953,6 +955,7 @@ public class MainnetEVMs {
public static EVM prague(final EvmConfiguration evmConfiguration) {
return prague(DEV_NET_CHAIN_ID, evmConfiguration);
}
/**
* Prague evm.
*
@@ -1020,6 +1023,7 @@ public class MainnetEVMs {
public static EVM osaka(final EvmConfiguration evmConfiguration) {
return osaka(DEV_NET_CHAIN_ID, evmConfiguration);
}
/**
* Osaka evm.
*
@@ -1087,6 +1091,7 @@ public class MainnetEVMs {
public static EVM bogota(final EvmConfiguration evmConfiguration) {
return bogota(DEV_NET_CHAIN_ID, evmConfiguration);
}
/**
* Bogota evm.
*

View File

@@ -28,8 +28,10 @@ public interface Account extends AccountState {
/** The constant DEFAULT_NONCE. */
long DEFAULT_NONCE = 0L;
/** The constant MAX_NONCE. */
long MAX_NONCE = -1; // per twos compliment rules -1 will be the unsigned max number
/** The constant DEFAULT_BALANCE. */
Wei DEFAULT_BALANCE = Wei.ZERO;

View File

@@ -25,12 +25,16 @@ public final class CodeSection {
/** The length. */
final int length;
/** The Inputs. */
final int inputs;
/** The Outputs. */
final int outputs;
/** The Max stack height. */
final int maxStackHeight;
/** The byte offset from the beginning of the container that the section starts at */
final int entryPoint;

View File

@@ -25,10 +25,13 @@ public class EOFLayout {
/** The Section Terminator. */
static final int SECTION_TERMINATOR = 0x00;
/** The Section types. */
static final int SECTION_TYPES = 0x01;
/** The Section code. */
static final int SECTION_CODE = 0x02;
/** The Section data. */
static final int SECTION_DATA = 0x03;

View File

@@ -31,6 +31,7 @@ public class SimpleWorld implements WorldUpdater {
/** The Parent. */
SimpleWorld parent;
/** The Accounts. */
Map<Address, SimpleAccount> accounts = new HashMap<>();

View File

@@ -19,42 +19,57 @@ public interface ExceptionalHaltReason {
/** The constant NONE. */
ExceptionalHaltReason NONE = DefaultExceptionalHaltReason.NONE;
/** The constant INSUFFICIENT_GAS. */
ExceptionalHaltReason INSUFFICIENT_GAS = DefaultExceptionalHaltReason.INSUFFICIENT_GAS;
/** The constant INSUFFICIENT_STACK_ITEMS. */
ExceptionalHaltReason INSUFFICIENT_STACK_ITEMS =
DefaultExceptionalHaltReason.INSUFFICIENT_STACK_ITEMS;
/** The constant INVALID_JUMP_DESTINATION. */
ExceptionalHaltReason INVALID_JUMP_DESTINATION =
DefaultExceptionalHaltReason.INVALID_JUMP_DESTINATION;
/** The constant INVALID_OPERATION. */
ExceptionalHaltReason INVALID_OPERATION = DefaultExceptionalHaltReason.INVALID_OPERATION;
/** The constant INVALID_RETURN_DATA_BUFFER_ACCESS. */
ExceptionalHaltReason INVALID_RETURN_DATA_BUFFER_ACCESS =
DefaultExceptionalHaltReason.INVALID_RETURN_DATA_BUFFER_ACCESS;
/** The constant TOO_MANY_STACK_ITEMS. */
ExceptionalHaltReason TOO_MANY_STACK_ITEMS = DefaultExceptionalHaltReason.TOO_MANY_STACK_ITEMS;
/** The constant ILLEGAL_STATE_CHANGE. */
ExceptionalHaltReason ILLEGAL_STATE_CHANGE = DefaultExceptionalHaltReason.ILLEGAL_STATE_CHANGE;
/** The constant OUT_OF_BOUNDS. */
ExceptionalHaltReason OUT_OF_BOUNDS = DefaultExceptionalHaltReason.OUT_OF_BOUNDS;
/** The constant CODE_TOO_LARGE. */
ExceptionalHaltReason CODE_TOO_LARGE = DefaultExceptionalHaltReason.CODE_TOO_LARGE;
/** The constant INVALID_CODE. */
ExceptionalHaltReason INVALID_CODE = DefaultExceptionalHaltReason.INVALID_CODE;
/** The constant PRECOMPILE_ERROR. */
ExceptionalHaltReason PRECOMPILE_ERROR = DefaultExceptionalHaltReason.PRECOMPILE_ERROR;
/** The constant CODE_SECTION_MISSING. */
ExceptionalHaltReason CODE_SECTION_MISSING = DefaultExceptionalHaltReason.CODE_SECTION_MISSING;
/** The constant INCORRECT_CODE_SECTION_RETURN_OUTPUTS. */
ExceptionalHaltReason INCORRECT_CODE_SECTION_RETURN_OUTPUTS =
DefaultExceptionalHaltReason.INCORRECT_CODE_SECTION_RETURN_OUTPUTS;
/** The constant TOO_FEW_INPUTS_FOR_CODE_SECTION. */
ExceptionalHaltReason TOO_FEW_INPUTS_FOR_CODE_SECTION =
DefaultExceptionalHaltReason.TOO_FEW_INPUTS_FOR_CODE_SECTION;
/** The constant JUMPF_STACK_MISMATCH. */
ExceptionalHaltReason JUMPF_STACK_MISMATCH = DefaultExceptionalHaltReason.JUMPF_STACK_MISMATCH;
/** The constant EOF_CREATE_VERSION_INCOMPATIBLE. */
ExceptionalHaltReason EOF_CREATE_VERSION_INCOMPATIBLE =
DefaultExceptionalHaltReason.EOF_CREATE_VERSION_INCOMPATIBLE;

View File

@@ -944,6 +944,7 @@ public class MessageFrame {
public void addCreate(final Address address) {
txValues.creates().add(address);
}
/**
* Add addresses to the create set if they are not already present.
*
@@ -1118,6 +1119,7 @@ public class MessageFrame {
public int getDepth() {
return getMessageStackSize() - 1;
}
/**
* Returns the recipient that originated the message.
*

View File

@@ -28,8 +28,10 @@ public class PetersburgGasCalculator extends ConstantinopleGasCalculator {
/** Same as {#link {@link FrontierGasCalculator#STORAGE_SET_GAS_COST} */
private static final long STORAGE_SET_GAS_COST = 20_000L;
/** Same as {#link {@link FrontierGasCalculator#STORAGE_RESET_GAS_COST} */
private static final long STORAGE_RESET_GAS_COST = 5_000L;
/** Same as {#link {@link FrontierGasCalculator#STORAGE_RESET_REFUND_AMOUNT} */
private static final long STORAGE_RESET_REFUND_AMOUNT = 15_000L;

View File

@@ -1,4 +1,5 @@
package org.hyperledger.besu.evm.gascalculator;
/*
* Copyright contributors to Hyperledger Besu.
*

View File

@@ -25,8 +25,10 @@ public class ReturnStack extends FlexStack<ReturnStack.ReturnStackItem> {
/** The Code section index. */
final int codeSectionIndex;
/** The Pc. */
final int pc;
/** The Stack height. */
final int stackHeight;

View File

@@ -28,11 +28,13 @@ public abstract class AbstractFixedCostOperation extends AbstractOperation {
/** The Success response. */
protected final OperationResult successResponse;
/** The Out of gas response. */
protected final OperationResult outOfGasResponse;
private final OperationResult underflowResponse;
private final OperationResult overflowResponse;
/** The Gas cost. */
protected final long gasCost;

View File

@@ -25,6 +25,7 @@ public class CallFOperation extends AbstractOperation {
/** The constant OPCODE. */
public static final int OPCODE = 0xe3;
/** The Call F success. */
static final OperationResult callfSuccess = new OperationResult(5, null);

View File

@@ -24,8 +24,10 @@ public class DupOperation extends AbstractFixedCostOperation {
/** The constant DUP_BASE. */
public static final int DUP_BASE = 0x7F;
/** The Dup success operation result. */
static final OperationResult dupSuccess = new OperationResult(3, null);
/** The Underflow response. */
protected final Operation.OperationResult underflowResponse;

View File

@@ -24,9 +24,11 @@ public class InvalidOperation extends AbstractOperation {
/** The constant OPCODE. */
public static final int OPCODE = 0xFE;
/** The constant INVALID_RESULT. */
public static final OperationResult INVALID_RESULT =
new OperationResult(0, ExceptionalHaltReason.INVALID_OPERATION);
/** The Invalid operation result. */
protected final OperationResult invalidResult;

View File

@@ -25,6 +25,7 @@ public class JumpFOperation extends AbstractOperation {
/** The constant OPCODE. */
public static final int OPCODE = 0xe5;
/** The Jump F success operation result. */
static final OperationResult jumpfSuccess = new OperationResult(3, null);

View File

@@ -25,8 +25,10 @@ public interface Operation {
class OperationResult {
/** The Gas cost. */
final long gasCost;
/** The Halt reason. */
final ExceptionalHaltReason haltReason;
/** The increment. */
final int pcIncrement;

View File

@@ -25,6 +25,7 @@ public class PushOperation extends AbstractFixedCostOperation {
/** The constant PUSH_BASE. */
public static final int PUSH_BASE = 0x5F;
/** The constant PUSH_MAX. */
public static final int PUSH_MAX = 0x7F;

View File

@@ -23,6 +23,7 @@ public class RetFOperation extends AbstractOperation {
/** The Opcode. */
public static final int OPCODE = 0xe4;
/** The Ret F success. */
static final OperationResult retfSuccess = new OperationResult(3, null);

View File

@@ -29,6 +29,7 @@ public class ReturnDataCopyOperation extends AbstractOperation {
/** The constant INVALID_RETURN_DATA_BUFFER_ACCESS. */
protected static final OperationResult INVALID_RETURN_DATA_BUFFER_ACCESS =
new OperationResult(0L, ExceptionalHaltReason.INVALID_RETURN_DATA_BUFFER_ACCESS);
/** The constant OUT_OF_BOUNDS. */
protected static final OperationResult OUT_OF_BOUNDS =
new OperationResult(0L, ExceptionalHaltReason.OUT_OF_BOUNDS);

View File

@@ -31,6 +31,7 @@ public class SStoreOperation extends AbstractOperation {
/** The constant FRONTIER_MINIMUM. */
public static final long FRONTIER_MINIMUM = 0L;
/** The constant EIP_1706_MINIMUM. */
public static final long EIP_1706_MINIMUM = 2300L;

View File

@@ -26,10 +26,12 @@ public class SwapOperation extends AbstractFixedCostOperation {
/** The constant SWAP_BASE. */
public static final int SWAP_BASE = 0x8F;
/** The Swap operation success result. */
static final OperationResult swapSuccess = new OperationResult(3, null);
private final int index;
/** The operation result due to underflow. */
protected final Operation.OperationResult underflowResponse;

View File

@@ -43,6 +43,7 @@ public class AltBN128PairingPrecompiledContract extends AbstractAltBnPrecompiled
/** The constant FALSE. */
static final Bytes FALSE =
Bytes.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000");
/** The constant TRUE. */
public static final Bytes TRUE =
Bytes.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001");

View File

@@ -36,6 +36,7 @@ public class ECRECPrecompiledContract extends AbstractPrecompiledContract {
private static final int V_BASE = 27;
final SignatureAlgorithm signatureAlgorithm;
/**
* Instantiates a new ECREC precompiled contract with the default signature algorithm.
*

View File

@@ -850,6 +850,14 @@
<sha256 value="4142a244523fa5cda9cceece41b7baaadf6f06e4fcdaf2e04783a8a5f4a324e7" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.google.googlejavaformat" name="google-java-format" version="1.22.0">
<artifact name="google-java-format-1.22.0.jar">
<sha256 value="4f4bdba0f2a3d7e84be47683a0c2a4ba69024d29d906d09784181f68f04af792" origin="Generated by Gradle"/>
</artifact>
<artifact name="google-java-format-1.22.0.pom">
<sha256 value="857969f274d7d56f55949042b93e8392f8f2e5208446eee25a85cafc594090a5" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.google.googlejavaformat" name="google-java-format" version="1.5">
<artifact name="google-java-format-1.5.jar">
<sha256 value="aa19ad7850fb85178aa22f2fddb163b84d6ce4d0035872f30d4408195ca1144e" origin="Generated by Gradle"/>
@@ -868,6 +876,11 @@
<sha256 value="b2ce276ca749d1af9f345f63eef2866e09b9e23f31095d17f2d11107c861cea6" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.google.googlejavaformat" name="google-java-format-parent" version="1.22.0">
<artifact name="google-java-format-parent-1.22.0.pom">
<sha256 value="7e4c16f4228f602003058f640a0392a35500b0e33f930a43c562153778f0b8ac" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.google.googlejavaformat" name="google-java-format-parent" version="1.5">
<artifact name="google-java-format-parent-1.5.pom">
<sha256 value="13aaf29158343f8b9c7dd7d3f58610290b05ad29ea69c7b9504869e47fbf6319" origin="Generated by Gradle"/>

View File

@@ -56,6 +56,7 @@ public enum BesuMetricCategory implements MetricCategory {
STRATUM("stratum");
private static final Optional<String> BESU_PREFIX = Optional.of("besu_");
/** The constant DEFAULT_METRIC_CATEGORIES. */
public static final Set<MetricCategory> DEFAULT_METRIC_CATEGORIES;

View File

@@ -23,10 +23,13 @@ public class RunnableCounter implements Counter {
/** The Backed counter. */
protected final Counter backedCounter;
/** The Task. */
protected final Runnable task;
/** The Step. */
protected final int step;
/** The Step counter. */
protected final AtomicLong stepCounter;

View File

@@ -36,31 +36,39 @@ public class NoOpMetricsSystem implements ObservableMetricsSystem {
/** The constant NO_OP_COUNTER. */
public static final Counter NO_OP_COUNTER = new NoOpCounter();
/** The constant NO_OP_GAUGE. */
public static final LabelledGauge NO_OP_GAUGE = new NoOpValueCollector();
private static final OperationTimer.TimingContext NO_OP_TIMING_CONTEXT = () -> 0;
/** The constant NO_OP_OPERATION_TIMER. */
public static final OperationTimer NO_OP_OPERATION_TIMER = () -> NO_OP_TIMING_CONTEXT;
/** The constant NO_OP_LABELLED_1_COUNTER. */
public static final LabelledMetric<Counter> NO_OP_LABELLED_1_COUNTER =
new LabelCountingNoOpMetric<>(1, NO_OP_COUNTER);
/** The constant NO_OP_LABELLED_2_COUNTER. */
public static final LabelledMetric<Counter> NO_OP_LABELLED_2_COUNTER =
new LabelCountingNoOpMetric<>(2, NO_OP_COUNTER);
/** The constant NO_OP_LABELLED_3_COUNTER. */
public static final LabelledMetric<Counter> NO_OP_LABELLED_3_COUNTER =
new LabelCountingNoOpMetric<>(3, NO_OP_COUNTER);
/** The constant NO_OP_LABELLED_1_OPERATION_TIMER. */
public static final LabelledMetric<OperationTimer> NO_OP_LABELLED_1_OPERATION_TIMER =
new LabelCountingNoOpMetric<>(1, NO_OP_OPERATION_TIMER);
/** The constant NO_OP_LABELLED_1_GAUGE. */
public static final LabelledGauge NO_OP_LABELLED_1_GAUGE =
new LabelledGaugeNoOpMetric(1, NO_OP_GAUGE);
/** The constant NO_OP_LABELLED_2_GAUGE. */
public static final LabelledGauge NO_OP_LABELLED_2_GAUGE =
new LabelledGaugeNoOpMetric(2, NO_OP_GAUGE);
/** The constant NO_OP_LABELLED_3_GAUGE. */
public static final LabelledGauge NO_OP_LABELLED_3_GAUGE =
new LabelledGaugeNoOpMetric(3, NO_OP_GAUGE);
@@ -176,6 +184,7 @@ public class NoOpMetricsSystem implements ObservableMetricsSystem {
/** The Label count. */
final int labelCount;
/** The Fake metric. */
final T fakeMetric;
@@ -203,6 +212,7 @@ public class NoOpMetricsSystem implements ObservableMetricsSystem {
public static class LabelledGaugeNoOpMetric implements LabelledGauge {
/** The Label count. */
final int labelCount;
/** The Label values cache. */
final List<String> labelValuesCache = new ArrayList<>();

View File

@@ -31,15 +31,19 @@ import com.google.common.base.MoreObjects;
/** The Metrics configuration. */
public class MetricsConfiguration {
private static final String DEFAULT_METRICS_HOST = "127.0.0.1";
/** The constant DEFAULT_METRICS_PORT. */
public static final int DEFAULT_METRICS_PORT = 9545;
private static final MetricsProtocol DEFAULT_METRICS_PROTOCOL = MetricsProtocol.PROMETHEUS;
private static final String DEFAULT_METRICS_PUSH_HOST = "127.0.0.1";
/** The constant DEFAULT_METRICS_PUSH_PORT. */
public static final int DEFAULT_METRICS_PUSH_PORT = 9001;
/** The constant DEFAULT_METRICS_TIMERS_ENABLED. */
public static final Boolean DEFAULT_METRICS_TIMERS_ENABLED = true;
/** The constant DEFAULT_METRICS_IDLE_TIMEOUT_SECONDS. */
public static final int DEFAULT_METRICS_IDLE_TIMEOUT_SECONDS = 60;

View File

@@ -35,10 +35,13 @@ public class RocksDBStats {
/** The Labels. */
static final List<String> LABELS = Collections.singletonList("quantile");
/** The Label 50. */
static final List<String> LABEL_50 = Collections.singletonList("0.5");
/** The Label 95. */
static final List<String> LABEL_95 = Collections.singletonList("0.95");
/** The Label 99. */
static final List<String> LABEL_99 = Collections.singletonList("0.99");

View File

@@ -134,8 +134,9 @@ public class CmsCreator {
case "RSA" -> {
return "SHA256WithRSAEncryption";
}
default -> throw new UnsupportedOperationException(
"Private key algorithm not supported: " + pub.getAlgorithm());
default ->
throw new UnsupportedOperationException(
"Private key algorithm not supported: " + pub.getAlgorithm());
}
}
}

View File

@@ -29,6 +29,7 @@ public class PkiKeyStoreConfiguration {
/** The constant DEFAULT_KEYSTORE_TYPE. */
public static String DEFAULT_KEYSTORE_TYPE = "PKCS12";
/** The constant DEFAULT_CERTIFICATE_ALIAS. */
public static String DEFAULT_CERTIFICATE_ALIAS = "validator";

Some files were not shown because too many files have changed in this diff Show More