diff --git a/CHANGELOG.md b/CHANGELOG.md index 09f21080a4c..d0f87d65a0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,20 +1,28 @@ # Changelog +## 22.10.0 +### Breaking Changes +- Version 22.10.0 will require Java 17 to build and run. + ## 22.10.0-RC2 ### Breaking Changes - Flexible Privacy Groups (early access) support to Tessera's EC encryptor (contracts modified) [#4282](https://github.com/hyperledger/besu/pull/4282) * Before this change, the `bytes32` type was used for the enclave public keys, just supporting encryptors with public keys of that length (like the default NaCl) * For the EC encryptor, the encoded public key length is 91 -- `--tx-pool-hashes-max-size` option removed (deprecated in 22.1.3). +- `--tx-pool-hashes-max-size` option removed (deprecated in 22.1.3) +- `--Xmerge-support` option remove (deprecated in 22.4.2) [#4518](https://github.com/hyperledger/besu/pull/4518) ### Additions and Improvements - Improved RLP processing of zero-length string as 0x80 [#4283](https://github.com/hyperledger/besu/pull/4283) [#4388](https://github.com/hyperledger/besu/issues/4388) - Increased level of detail in JSON-RPC parameter error log messages [#4510](https://github.com/hyperledger/besu/pull/4510) +- New unstable configuration options to set the maximum time, in milliseconds, a PoS block creation jobs is allowed to run [#4519](https://github.com/hyperledger/besu/pull/4519) ### Bug Fixes - Corrects emission of blockadded events when rewinding during a re-org. Fix for [#4495](https://github.com/hyperledger/besu/issues/4495) - Always return a transaction type for pending transactions [#4364](https://github.com/hyperledger/besu/pull/4364) -- Fixed default fromBlock value in eth_getLogs RPC handler [#4513](https://github.com/hyperledger/besu/pull/4513) +- Avoid a cyclic reference while printing EngineExchangeTransitionConfigurationParameter [#4357](https://github.com/hyperledger/besu/pull/4357) +- In GraphQL update scalar parsing to be variable friendly [#4522](https://github.com/hyperledger/besu/pull/4522) +- Fixed default fromBlock value and improved parameter interpetation in eth_getLogs RPC handler [#4513](https://github.com/hyperledger/besu/pull/4513) ### Download Links diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index 42dd9f631e8..71b2f29a0f7 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -59,7 +59,6 @@ import org.hyperledger.besu.cli.options.unstable.EvmOptions; import org.hyperledger.besu.cli.options.unstable.IpcOptions; import org.hyperledger.besu.cli.options.unstable.LauncherOptions; -import org.hyperledger.besu.cli.options.unstable.MergeOptions; import org.hyperledger.besu.cli.options.unstable.MetricsCLIOptions; import org.hyperledger.besu.cli.options.unstable.MiningOptions; import org.hyperledger.besu.cli.options.unstable.NatOptions; @@ -282,7 +281,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable { private final NatOptions unstableNatOptions = NatOptions.create(); private final NativeLibraryOptions unstableNativeLibraryOptions = NativeLibraryOptions.create(); private final RPCOptions unstableRPCOptions = RPCOptions.create(); - private final MergeOptions mergeOptions = MergeOptions.create(); final LauncherOptions unstableLauncherOptions = LauncherOptions.create(); private final PrivacyPluginOptions unstablePrivacyPluginOptions = PrivacyPluginOptions.create(); private final EvmOptions unstableEvmOptions = EvmOptions.create(); @@ -1521,7 +1519,6 @@ private void handleUnstableOptions() { .put("Mining", unstableMiningOptions) .put("Native Library", unstableNativeLibraryOptions) .put("Launcher", unstableLauncherOptions) - .put("Merge", mergeOptions) .put("EVM Options", unstableEvmOptions) .put("IPC Options", unstableIpcOptions) .build(); @@ -1762,6 +1759,12 @@ private void validateMiningParams() { "Unable to mine with Stratum if mining is disabled. Either disable Stratum mining (remove --miner-stratum-enabled) " + "or specify mining is enabled (--miner-enabled)"); } + if (unstableMiningOptions.getPosBlockCreationMaxTime() <= 0 + || unstableMiningOptions.getPosBlockCreationMaxTime() + > MiningParameters.DEFAULT_POS_BLOCK_CREATION_MAX_TIME) { + throw new ParameterException( + this.commandLine, "--Xpos-block-creation-max-time must be positive and ≤ 12000"); + } } protected void validateP2PInterface(final String p2pInterface) { @@ -2096,6 +2099,7 @@ public BesuControllerBuilder getControllerBuilder() { .remoteSealersTimeToLive(unstableMiningOptions.getRemoteSealersTimeToLive()) .powJobTimeToLive(unstableMiningOptions.getPowJobTimeToLive()) .maxOmmerDepth(unstableMiningOptions.getMaxOmmersDepth()) + .posBlockCreationMaxTime(unstableMiningOptions.getPosBlockCreationMaxTime()) .build()) .transactionPoolConfiguration(buildTransactionPoolConfiguration()) .nodeKey(new NodeKey(securityModule())) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/MergeOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/MergeOptions.java deleted file mode 100644 index 2f0614e943b..00000000000 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/MergeOptions.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.cli.options.unstable; - -import java.util.Stack; - -import net.consensys.quorum.mainnet.launcher.options.Options; -import org.slf4j.LoggerFactory; -import picocli.CommandLine; -import picocli.CommandLine.Option; - -/** DEPRECATED in favor of genesis config. */ -public class MergeOptions implements Options { - // To make it easier for tests to reset the value to default - private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(MergeOptions.class); - - @Option( - hidden = true, - names = {"--Xmerge-support"}, - description = "Deprecated config parameter, do not use", - arity = "1", - parameterConsumer = MergeConfigConsumer.class) - @SuppressWarnings({"FieldCanBeFinal", "UnusedVariable"}) - private static boolean deprecatedMergeEnabled = false; - - public static MergeOptions create() { - return new MergeOptions(); - } - - @SuppressWarnings({"JdkObsolete"}) - static class MergeConfigConsumer implements CommandLine.IParameterConsumer { - @Override - public void consumeParameters( - final Stack args, - final CommandLine.Model.ArgSpec argSpec, - final CommandLine.Model.CommandSpec commandSpec) { - LOG.warn( - "--Xmerge-support parameter has been deprecated and will be removed in a future release. " - + "Merge support is implicitly enabled by the presence of terminalTotalDifficulty in the genesis config."); - Boolean.parseBoolean(args.pop()); - } - } -} diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/MiningOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/MiningOptions.java index e684ca3b411..484c579d0f4 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/MiningOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/MiningOptions.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.cli.options.unstable; import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_MAX_OMMERS_DEPTH; +import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_POS_BLOCK_CREATION_MAX_TIME; import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_POW_JOB_TTL; import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_REMOTE_SEALERS_LIMIT; import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_REMOTE_SEALERS_TTL; @@ -58,6 +59,13 @@ public class MiningOptions { description = "Extranonce for Stratum network miners (default: ${DEFAULT-VALUE})") private String stratumExtranonce = "080c"; + @CommandLine.Option( + hidden = true, + names = {"--Xpos-block-creation-max-time"}, + description = + "Specifies the maximum time, in milliseconds, a PoS block creation jobs is allowed to run. Must be positive and ≤ 12000 (default: ${DEFAULT-VALUE} milliseconds)") + private final Long posBlockCreationMaxTime = DEFAULT_POS_BLOCK_CREATION_MAX_TIME; + public static MiningOptions create() { return new MiningOptions(); } @@ -81,4 +89,8 @@ public Long getPowJobTimeToLive() { public int getMaxOmmersDepth() { return maxOmmersDepth; } + + public Long getPosBlockCreationMaxTime() { + return posBlockCreationMaxTime; + } } diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index 3e07c4b3c9c..f7db8ce1daf 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -36,6 +36,7 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.NET; import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.PERM; import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.WEB3; +import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_POS_BLOCK_CREATION_MAX_TIME; import static org.hyperledger.besu.ethereum.p2p.config.DefaultDiscoveryConfiguration.GOERLI_BOOTSTRAP_NODES; import static org.hyperledger.besu.ethereum.p2p.config.DefaultDiscoveryConfiguration.GOERLI_DISCOVERY_URL; import static org.hyperledger.besu.ethereum.p2p.config.DefaultDiscoveryConfiguration.MAINNET_BOOTSTRAP_NODES; @@ -226,7 +227,7 @@ public void callingVersionDisplayBesuInfoVersion() { // Testing default values @Test - public void callingBesuCommandWithoutOptionsMustSyncWithDefaultValues() throws Exception { + public void callingBesuCommandWithoutOptionsMustSyncWithDefaultValues() { parseCommand(); final int maxPeers = 25; @@ -5327,4 +5328,35 @@ public void logWarnIfFastSyncMinPeersUsedWithFullSync() { assertThat(commandErrorOutput.toString(UTF_8)) .contains("--fast-sync-min-peers can't be used with FULL sync-mode"); } + + @Test + public void posBlockCreationMaxTimeDefaultValue() { + parseCommand(); + assertThat(getPosBlockCreationMaxTimeValue()).isEqualTo(DEFAULT_POS_BLOCK_CREATION_MAX_TIME); + } + + @Test + public void posBlockCreationMaxTimeOption() { + parseCommand("--Xpos-block-creation-max-time", "7000"); + assertThat(getPosBlockCreationMaxTimeValue()).isEqualTo(7000L); + } + + private long getPosBlockCreationMaxTimeValue() { + final ArgumentCaptor miningArg = + ArgumentCaptor.forClass(MiningParameters.class); + + verify(mockControllerBuilder).miningParameters(miningArg.capture()); + verify(mockControllerBuilder).build(); + + assertThat(commandOutput.toString(UTF_8)).isEmpty(); + assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); + return miningArg.getValue().getPosBlockCreationMaxTime(); + } + + @Test + public void posBlockCreationMaxTimeOutOfAllowedRange() { + parseCommand("--Xpos-block-creation-max-time", "17000"); + assertThat(commandErrorOutput.toString(UTF_8)) + .contains("--Xpos-block-creation-max-time must be positive and ≤ 12000"); + } } diff --git a/besu/src/test/resources/everything_config.toml b/besu/src/test/resources/everything_config.toml index 41c831566ec..629e11bf119 100644 --- a/besu/src/test/resources/everything_config.toml +++ b/besu/src/test/resources/everything_config.toml @@ -136,6 +136,8 @@ miner-stratum-host="0.0.0.0" miner-stratum-port=8008 Xminer-remote-sealers-limit=1000 Xminer-remote-sealers-hashrate-ttl=10 +Xpos-block-creation-max-time=5 + # Pruning pruning-enabled=true pruning-blocks-retained=1024 diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java index 315bbeca97d..0bf5f9336bc 100644 --- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java +++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java @@ -214,7 +214,7 @@ private void tryToBuildBetterBlock( final PayloadIdentifier payloadIdentifier, final MergeBlockCreator mergeBlockCreator) { - long remainingTime = miningParameters.getPosBlockCreationTimeout(); + long remainingTime = miningParameters.getPosBlockCreationMaxTime(); final Supplier blockCreator = () -> mergeBlockCreator.createBlock(Optional.empty(), random, timestamp); // start working on a full block and update the payload value and candidate when it's ready diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java index 5c440d066e8..e312fd97d5c 100644 --- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java +++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java @@ -215,7 +215,7 @@ public void shouldRetryBlockCreationIfStillHaveTime() { @Test public void shouldStopRetryBlockCreationIfTimeExpired() { when(mergeContext.getFinalized()).thenReturn(Optional.empty()); - doReturn(1L).when(miningParameters).getPosBlockCreationTimeout(); + doReturn(1L).when(miningParameters).getPosBlockCreationMaxTime(); reset(ethContext, ethScheduler); when(ethContext.getScheduler()).thenReturn(ethScheduler); when(ethScheduler.scheduleComputationTask(any())) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/Scalars.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/Scalars.java index ac396c3d5b0..bfaf092b3d7 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/Scalars.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/Scalars.java @@ -15,7 +15,6 @@ package org.hyperledger.besu.ethereum.api.graphql.internal; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; import graphql.language.IntValue; @@ -28,156 +27,239 @@ import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; -import org.apache.tuweni.units.bigints.UInt256Value; public class Scalars { - private static final Coercing ADDRESS_COERCING = - new Coercing() { + private Scalars() {} + + private static final Coercing ADDRESS_COERCING = + new Coercing() { + Address convertImpl(final Object input) { + if (input instanceof Address) { + return (Address) input; + } else if (input instanceof Bytes) { + if (((Bytes) input).size() <= 20) { + return Address.wrap((Bytes) input); + } else { + return null; + } + } else if (input instanceof StringValue) { + return convertImpl(((StringValue) input).getValue()); + } else if (input instanceof String) { + try { + return Address.fromHexStringStrict((String) input); + } catch (IllegalArgumentException iae) { + return null; + } + } else { + return null; + } + } + @Override public String serialize(final Object input) throws CoercingSerializeException { - if (input instanceof Address) { - return input.toString(); + Address result = convertImpl(input); + if (result != null) { + return result.toHexString(); + } else { + throw new CoercingSerializeException("Unable to serialize " + input + " as an Address"); } - throw new CoercingSerializeException("Unable to serialize " + input + " as an Address"); } @Override - public String parseValue(final Object input) throws CoercingParseValueException { - if (input instanceof Address) { - return input.toString(); + public Address parseValue(final Object input) throws CoercingParseValueException { + Address result = convertImpl(input); + if (result != null) { + return result; + } else { + throw new CoercingParseValueException( + "Unable to parse variable value " + input + " as an Address"); } - throw new CoercingParseValueException( - "Unable to parse variable value " + input + " as an Address"); } @Override public Address parseLiteral(final Object input) throws CoercingParseLiteralException { - if (!(input instanceof StringValue)) { - throw new CoercingParseLiteralException("Value is not any Address : '" + input + "'"); - } - String inputValue = ((StringValue) input).getValue(); - try { - return Address.fromHexStringStrict(inputValue); - } catch (final IllegalArgumentException e) { + Address result = convertImpl(input); + if (result != null) { + return result; + } else { throw new CoercingParseLiteralException("Value is not any Address : '" + input + "'"); } } }; - private static final Coercing BIG_INT_COERCING = - new Coercing() { + private static final Coercing BIG_INT_COERCING = + new Coercing() { + + String convertImpl(final Object input) { + if (input instanceof String) { + try { + return Bytes.fromHexStringLenient((String) input).toShortHexString(); + } catch (IllegalArgumentException iae) { + return null; + } + } else if (input instanceof Bytes) { + return ((Bytes) input).toShortHexString(); + } else if (input instanceof StringValue) { + return convertImpl(((StringValue) input).getValue()); + } else if (input instanceof IntValue) { + return UInt256.valueOf(((IntValue) input).getValue()).toShortHexString(); + } else { + return null; + } + } + @Override public String serialize(final Object input) throws CoercingSerializeException { - if (input instanceof UInt256Value) { - return ((UInt256Value) input).toShortHexString(); + var result = convertImpl(input); + if (result != null) { + return result; + } else { + throw new CoercingSerializeException("Unable to serialize " + input + " as an BigInt"); } - throw new CoercingSerializeException("Unable to serialize " + input + " as an BigInt"); } @Override public String parseValue(final Object input) throws CoercingParseValueException { - if (input instanceof UInt256Value) { - return ((UInt256Value) input).toShortHexString(); + var result = convertImpl(input); + if (result != null) { + return result; + } else { + throw new CoercingParseValueException( + "Unable to parse variable value " + input + " as an BigInt"); } - throw new CoercingParseValueException( - "Unable to parse variable value " + input + " as an BigInt"); } @Override - public UInt256 parseLiteral(final Object input) throws CoercingParseLiteralException { - try { - if (input instanceof StringValue) { - return UInt256.fromHexString(((StringValue) input).getValue()); - } else if (input instanceof IntValue) { - return UInt256.valueOf(((IntValue) input).getValue()); - } - } catch (final IllegalArgumentException e) { - // fall through + public String parseLiteral(final Object input) throws CoercingParseLiteralException { + var result = convertImpl(input); + if (result != null) { + return result; + } else { + throw new CoercingParseLiteralException("Value is not any BigInt : '" + input + "'"); } - throw new CoercingParseLiteralException("Value is not any BigInt : '" + input + "'"); } }; - private static final Coercing BYTES_COERCING = - new Coercing() { + private static final Coercing BYTES_COERCING = + new Coercing() { + + Bytes convertImpl(final Object input) { + if (input instanceof Bytes) { + return (Bytes) input; + } else if (input instanceof StringValue) { + return convertImpl(((StringValue) input).getValue()); + } else if (input instanceof String) { + if (!Quantity.isValid((String) input)) { + throw new CoercingParseLiteralException( + "Bytes value '" + input + "' is not prefixed with 0x"); + } + try { + return Bytes.fromHexStringLenient((String) input); + } catch (IllegalArgumentException iae) { + return null; + } + } else { + return null; + } + } + @Override public String serialize(final Object input) throws CoercingSerializeException { - if (input instanceof Bytes) { - return input.toString(); + var result = convertImpl(input); + if (result != null) { + return result.toHexString(); + } else { + throw new CoercingSerializeException("Unable to serialize " + input + " as an Bytes"); } - throw new CoercingSerializeException("Unable to serialize " + input + " as an Bytes"); } @Override - public String parseValue(final Object input) throws CoercingParseValueException { - if (input instanceof Bytes) { - return input.toString(); + public Bytes parseValue(final Object input) throws CoercingParseValueException { + var result = convertImpl(input); + if (result != null) { + return result; + } else { + throw new CoercingParseValueException( + "Unable to parse variable value " + input + " as an Bytes"); } - throw new CoercingParseValueException( - "Unable to parse variable value " + input + " as an Bytes"); } @Override public Bytes parseLiteral(final Object input) throws CoercingParseLiteralException { - if (!(input instanceof StringValue)) { - throw new CoercingParseLiteralException("Value is not any Bytes : '" + input + "'"); - } - String inputValue = ((StringValue) input).getValue(); - if (!Quantity.isValid(inputValue)) { - throw new CoercingParseLiteralException( - "Bytes value '" + inputValue + "' is not prefixed with 0x"); - } - try { - return Bytes.fromHexStringLenient(inputValue); - } catch (final IllegalArgumentException e) { + var result = convertImpl(input); + if (result != null) { + return result; + } else { throw new CoercingParseLiteralException("Value is not any Bytes : '" + input + "'"); } } }; - private static final Coercing BYTES32_COERCING = - new Coercing() { + private static final Coercing BYTES32_COERCING = + new Coercing() { + + Bytes32 convertImpl(final Object input) { + if (input instanceof Bytes32) { + return (Bytes32) input; + } else if (input instanceof Bytes) { + if (((Bytes) input).size() <= 32) { + return Bytes32.leftPad((Bytes) input); + } else { + return null; + } + } else if (input instanceof StringValue) { + return convertImpl((((StringValue) input).getValue())); + } else if (input instanceof String) { + if (!Quantity.isValid((String) input)) { + throw new CoercingParseLiteralException( + "Bytes32 value '" + input + "' is not prefixed with 0x"); + } else { + try { + return Bytes32.fromHexStringLenient((String) input); + } catch (IllegalArgumentException iae) { + return null; + } + } + } else { + return null; + } + } + @Override public String serialize(final Object input) throws CoercingSerializeException { - if (input instanceof Hash) { - return ((Hash) input).toString(); - } - if (input instanceof Bytes32) { - return input.toString(); + var result = convertImpl(input); + if (result == null) { + throw new CoercingSerializeException("Unable to serialize " + input + " as an Bytes32"); + } else { + return result.toHexString(); } - throw new CoercingSerializeException("Unable to serialize " + input + " as an Bytes32"); } @Override - public String parseValue(final Object input) throws CoercingParseValueException { - if (input instanceof Bytes32) { - return input.toString(); + public Bytes32 parseValue(final Object input) throws CoercingParseValueException { + var result = convertImpl(input); + if (result == null) { + throw new CoercingParseValueException( + "Unable to parse variable value " + input + " as an Bytes32"); + } else { + return result; } - throw new CoercingParseValueException( - "Unable to parse variable value " + input + " as an Bytes32"); } @Override public Bytes32 parseLiteral(final Object input) throws CoercingParseLiteralException { - if (!(input instanceof StringValue)) { - throw new CoercingParseLiteralException("Value is not any Bytes32 : '" + input + "'"); - } - String inputValue = ((StringValue) input).getValue(); - if (!Quantity.isValid(inputValue)) { - throw new CoercingParseLiteralException( - "Bytes32 value '" + inputValue + "' is not prefixed with 0x"); - } - try { - return Bytes32.fromHexStringLenient(inputValue); - } catch (final IllegalArgumentException e) { + var result = convertImpl(input); + if (result == null) { throw new CoercingParseLiteralException("Value is not any Bytes32 : '" + input + "'"); + } else { + return result; } } }; - private static final Coercing LONG_COERCING = - new Coercing() { + private static final Coercing LONG_COERCING = + new Coercing() { @Override public Number serialize(final Object input) throws CoercingSerializeException { if (input instanceof Number) { @@ -210,7 +292,7 @@ public Number parseValue(final Object input) throws CoercingParseValueException } @Override - public Object parseLiteral(final Object input) throws CoercingParseLiteralException { + public Number parseLiteral(final Object input) throws CoercingParseLiteralException { try { if (input instanceof IntValue) { return ((IntValue) input).getValue().longValue(); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfiguration.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfiguration.java index 0633a438380..83686f60f62 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfiguration.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfiguration.java @@ -30,9 +30,12 @@ import org.hyperledger.besu.ethereum.core.Difficulty; import java.util.Optional; +import java.util.function.Supplier; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.base.Suppliers; import io.vertx.core.Vertx; -import io.vertx.core.json.Json; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,6 +48,8 @@ public class EngineExchangeTransitionConfiguration extends ExecutionEngineJsonRp Difficulty.fromHexString( "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00"); + private static final Supplier mapperSupplier = Suppliers.memoize(ObjectMapper::new); + public EngineExchangeTransitionConfiguration( final Vertx vertx, final ProtocolContext protocolContext, @@ -69,7 +74,13 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) traceLambda( LOG, "received transitionConfiguration: {}", - () -> Json.encodePrettily(remoteTransitionConfiguration)); + () -> { + try { + return mapperSupplier.get().writeValueAsString(remoteTransitionConfiguration); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + }); final Optional maybeTerminalPoWBlockHeader = mergeContextOptional.flatMap(MergeContext::getTerminalPoWBlock); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayload.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayload.java index 206602c7c88..06851239211 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayload.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayload.java @@ -21,7 +21,6 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID; import static org.hyperledger.besu.util.Slf4jLambdaHelper.debugLambda; import static org.hyperledger.besu.util.Slf4jLambdaHelper.traceLambda; -import static org.hyperledger.besu.util.Slf4jLambdaHelper.warnLambda; import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator; import org.hyperledger.besu.datatypes.Hash; @@ -251,24 +250,28 @@ JsonRpcResponse respondWith( } // engine api calls are synchronous, no need for volatile - private long lastInvalidWarn = System.currentTimeMillis(); + private long lastInvalidWarn = 0; JsonRpcResponse respondWithInvalid( final Object requestId, final EnginePayloadParameter param, final Hash latestValidHash, final String validationError) { + final String invalidBlockLogMessage = + String.format( + "Invalid new payload: number: %s, hash: %s, parentHash: %s, latestValidHash: %s, status: %s, validationError: %s", + param.getBlockNumber(), + param.getBlockHash(), + param.getParentHash(), + latestValidHash == null ? null : latestValidHash.toHexString(), + INVALID.name(), + validationError); + // always log invalid at DEBUG + LOG.debug(invalidBlockLogMessage); + // periodically log at WARN if (lastInvalidWarn + ENGINE_API_LOGGING_THRESHOLD < System.currentTimeMillis()) { lastInvalidWarn = System.currentTimeMillis(); - warnLambda( - LOG, - "Invalid new payload: number: {}, hash: {}, parentHash: {}, latestValidHash: {}, status: {}, validationError: {}", - () -> param.getBlockNumber(), - () -> param.getBlockHash(), - () -> param.getParentHash(), - () -> latestValidHash == null ? null : latestValidHash.toHexString(), - INVALID::name, - () -> validationError); + LOG.warn(invalidBlockLogMessage); } return new JsonRpcSuccessResponse( requestId, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EngineExchangeTransitionConfigurationParameter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EngineExchangeTransitionConfigurationParameter.java index 61e7ccd982d..3833fa80c4f 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EngineExchangeTransitionConfigurationParameter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EngineExchangeTransitionConfigurationParameter.java @@ -39,10 +39,20 @@ public Difficulty getTerminalTotalDifficulty() { return terminalTotalDifficulty; } + @JsonProperty("terminalTotalDifficulty") + public String getTerminalTotalDifficultyAsHexString() { + return terminalTotalDifficulty.toShortHexString(); + } + public Hash getTerminalBlockHash() { return terminalBlockHash; } + @JsonProperty("terminalBlockHash") + public String getTerminalBlockHashAsHexString() { + return terminalBlockHash.toShortHexString(); + } + public long getTerminalBlockNumber() { return terminalBlockNumber; } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/EthGraphQLHttpBySpecTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/EthGraphQLHttpBySpecTest.java index 6dedc04a36e..a2280923d9c 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/EthGraphQLHttpBySpecTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/EthGraphQLHttpBySpecTest.java @@ -113,6 +113,11 @@ public static Collection specs() { specs.add("graphql_tooComplex"); specs.add("graphql_tooComplexSchema"); + specs.add("graphql_variable_address"); + specs.add("graphql_variable_bytes"); + specs.add("graphql_variable_bytes32"); + specs.add("graphql_variable_long"); + return specs; } @@ -128,7 +133,13 @@ private void graphQLCall(final String name) throws IOException { EthGraphQLHttpBySpecTest.class.getResource(testSpecFile), Charsets.UTF_8); final JsonObject spec = new JsonObject(json); final String rawRequestBody = spec.getString("request"); - final RequestBody requestBody = RequestBody.create(rawRequestBody, GRAPHQL); + final String rawVariables = spec.getString("variables"); + final RequestBody requestBody = + rawVariables == null + ? RequestBody.create(rawRequestBody, GRAPHQL) + : RequestBody.create( + "{ \"query\":\"" + rawRequestBody + "\", \"variables\": " + rawVariables + "}", + JSON); final Request request = new Request.Builder().post(requestBody).url(baseUrl).build(); importBlocks(1, BLOCKS.size()); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/AddressScalarTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/AddressScalarTest.java index 33a0e59289c..87153b49087 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/AddressScalarTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/AddressScalarTest.java @@ -27,10 +27,7 @@ import graphql.schema.GraphQLScalarType; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; -@RunWith(MockitoJUnitRunner.class) public class AddressScalarTest { private GraphQLScalarType scalar; @@ -43,13 +40,13 @@ public class AddressScalarTest { @Test public void parseValueTest() { - final String result = (String) scalar.getCoercing().parseValue(addr); - assertThat(result).isEqualTo(addrStr); + final Address result = (Address) scalar.getCoercing().parseValue(addrStr); + assertThat(result).isEqualTo(addr); } @Test public void parseValueErrorTest() { - assertThatThrownBy(() -> scalar.getCoercing().parseValue(addrStr)) + assertThatThrownBy(() -> scalar.getCoercing().parseValue(3.4f)) .isInstanceOf(CoercingParseValueException.class); } @@ -61,7 +58,7 @@ public void serializeTest() { @Test public void serializeErrorTest() { - assertThatThrownBy(() -> scalar.getCoercing().serialize(addrStr)) + assertThatThrownBy(() -> scalar.getCoercing().serialize(3.4f)) .isInstanceOf(CoercingSerializeException.class); } @@ -73,7 +70,7 @@ public void parseLiteralTest() { @Test public void parseLiteralErrorTest() { - assertThatThrownBy(() -> scalar.getCoercing().parseLiteral(addrStr)) + assertThatThrownBy(() -> scalar.getCoercing().parseLiteral(3.4f)) .isInstanceOf(CoercingParseLiteralException.class); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/BigIntScalarTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/BigIntScalarTest.java index 4f0ac678882..06fcfa42c2f 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/BigIntScalarTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/BigIntScalarTest.java @@ -27,17 +27,13 @@ import org.apache.tuweni.units.bigints.UInt256; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; -@RunWith(MockitoJUnitRunner.class) public class BigIntScalarTest { private GraphQLScalarType scalar; private final String str = "0x10"; private final UInt256 value = UInt256.fromHexString(str); - private final StringValue strValue = StringValue.newStringValue(str).build(); private final StringValue invalidStrValue = StringValue.newStringValue("0xgh").build(); @Test @@ -48,7 +44,7 @@ public void parseValueTest() { @Test public void parseValueErrorTest() { - assertThatThrownBy(() -> scalar.getCoercing().parseValue(str)) + assertThatThrownBy(() -> scalar.getCoercing().parseValue(3.2)) .isInstanceOf(CoercingParseValueException.class); } @@ -60,19 +56,19 @@ public void serializeTest() { @Test public void serializeErrorTest() { - assertThatThrownBy(() -> scalar.getCoercing().serialize(str)) + assertThatThrownBy(() -> scalar.getCoercing().serialize(3.2)) .isInstanceOf(CoercingSerializeException.class); } @Test public void parseLiteralTest() { - final UInt256 result = (UInt256) scalar.getCoercing().parseLiteral(strValue); - assertThat(result).isEqualTo(value); + final String result = (String) scalar.getCoercing().parseLiteral(value); + assertThat(result).isEqualTo(str); } @Test public void parseLiteralErrorTest() { - assertThatThrownBy(() -> scalar.getCoercing().parseLiteral(str)) + assertThatThrownBy(() -> scalar.getCoercing().parseLiteral(3.2)) .isInstanceOf(CoercingParseLiteralException.class); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/Bytes32ScalarTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/Bytes32ScalarTest.java index 56fc6c0e072..47e516c3b52 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/Bytes32ScalarTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/Bytes32ScalarTest.java @@ -27,10 +27,7 @@ import org.apache.tuweni.bytes.Bytes32; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; -@RunWith(MockitoJUnitRunner.class) public class Bytes32ScalarTest { private GraphQLScalarType scalar; @@ -42,13 +39,13 @@ public class Bytes32ScalarTest { @Test public void pareValueTest() { - final String result = (String) scalar.getCoercing().parseValue(value); - assertThat(result).isEqualTo(str); + final var result = scalar.getCoercing().parseValue(str); + assertThat(result).isEqualTo(value); } @Test public void parseValueErrorTest() { - assertThatThrownBy(() -> scalar.getCoercing().parseValue(str)) + assertThatThrownBy(() -> scalar.getCoercing().parseValue(3.2f)) .isInstanceOf(CoercingParseValueException.class); } @@ -60,7 +57,7 @@ public void serializeTest() { @Test public void serializeErrorTest() { - assertThatThrownBy(() -> scalar.getCoercing().serialize(str)) + assertThatThrownBy(() -> scalar.getCoercing().serialize(3.2f)) .isInstanceOf(CoercingSerializeException.class); } @@ -72,7 +69,7 @@ public void parseLiteralTest() { @Test public void parseLiteralErrorTest() { - assertThatThrownBy(() -> scalar.getCoercing().parseLiteral(str)) + assertThatThrownBy(() -> scalar.getCoercing().parseLiteral(3.2f)) .isInstanceOf(CoercingParseLiteralException.class); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/BytesScalarTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/BytesScalarTest.java index 493135d95f2..39ca321c3a5 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/BytesScalarTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/BytesScalarTest.java @@ -27,10 +27,7 @@ import org.apache.tuweni.bytes.Bytes; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; -@RunWith(MockitoJUnitRunner.class) public class BytesScalarTest { private GraphQLScalarType scalar; @@ -42,13 +39,13 @@ public class BytesScalarTest { @Test public void parseValueTest() { - final String result = (String) scalar.getCoercing().parseValue(value); - assertThat(result).isEqualTo(str); + final var result = scalar.getCoercing().parseValue(str); + assertThat(result).isEqualTo(value); } @Test public void parseValueErrorTest() { - assertThatThrownBy(() -> scalar.getCoercing().parseValue(str)) + assertThatThrownBy(() -> scalar.getCoercing().parseValue(3.2f)) .isInstanceOf(CoercingParseValueException.class); } @@ -60,7 +57,7 @@ public void serializeTest() { @Test public void serializeErrorTest() { - assertThatThrownBy(() -> scalar.getCoercing().serialize(str)) + assertThatThrownBy(() -> scalar.getCoercing().serialize(3.2f)) .isInstanceOf(CoercingSerializeException.class); } @@ -72,7 +69,7 @@ public void parseLiteralTest() { @Test public void parseLiteralErrorTest() { - assertThatThrownBy(() -> scalar.getCoercing().parseLiteral(str)) + assertThatThrownBy(() -> scalar.getCoercing().parseLiteral(3.2f)) .isInstanceOf(CoercingParseLiteralException.class); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/LongScalarTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/LongScalarTest.java index 5a1cfad7af4..d693d6e2c95 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/LongScalarTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/LongScalarTest.java @@ -26,10 +26,7 @@ import graphql.schema.GraphQLScalarType; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; -@RunWith(MockitoJUnitRunner.class) public class LongScalarTest { private GraphQLScalarType scalar; diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/graphql_variable_address.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/graphql_variable_address.json new file mode 100644 index 00000000000..79a162dd1bb --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/graphql_variable_address.json @@ -0,0 +1,14 @@ +{ + "variables": "{ \"address\": \"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\"}", + "request": "query getAddressBalance($address :Address!) { pending { account(address:$address) { balance} } }", + "response": { + "data": { + "pending": { + "account": { + "balance": "0x140" + } + } + } + }, + "statusCode": 200 +} \ No newline at end of file diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/graphql_variable_bytes.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/graphql_variable_bytes.json new file mode 100644 index 00000000000..c65dc75e41c --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/graphql_variable_bytes.json @@ -0,0 +1,10 @@ +{ + "variables" : "{ \"data\": \"0xf86d0485174876e800830222e0945aae326516b4f8fe08074b7e972e40a713048d62880de0b6b3a7640000801ba05d4e7998757264daab67df2ce6f7e7a0ae36910778a406ca73898c9899a32b9ea0674700d5c3d1d27f2e6b4469957dfd1a1c49bf92383d80717afc84eb05695d5b\"}", + "request" : "mutation postTransaction($data: Bytes!) { sendRawTransaction(data: $data) }", + "response":{ + "data" : { + "sendRawTransaction" : "0xbaabcc1bd699e7378451e4ce5969edb9bdcae76cb79bdacae793525c31e423c7" + } + }, + "statusCode": 200 +} \ No newline at end of file diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/graphql_variable_bytes32.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/graphql_variable_bytes32.json new file mode 100644 index 00000000000..1512cbdc402 --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/graphql_variable_bytes32.json @@ -0,0 +1,12 @@ +{ + "variables": "{ \"hash\": \"0xc8df1f061abb4d0c107b2b1a794ade8780b3120e681f723fe55a7be586d95ba6\"}", + "request": "query getBlock($hash :Bytes32!) { block(hash:$hash) { number } }", + "response": { + "data": { + "block": { + "number": 30 + } + } + }, + "statusCode": 200 +} \ No newline at end of file diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/graphql_variable_long.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/graphql_variable_long.json new file mode 100644 index 00000000000..4f1b8c5e264 --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/graphql_variable_long.json @@ -0,0 +1,17 @@ +{ + "variables": "{ \"block1\": \"0x1d\", \"block2\": \"0x1e\"}", + "request": "query getBlockRange($block1 :Long, $block2: Long) { blocks(from: $block1, to: $block2) { hash } }", + "response": { + "data": { + "blocks": [ + { + "hash": "0xf8cfa377bd766cdf22edb388dd08cc149e85d24f2796678c835f3c54ab930803" + }, + { + "hash": "0xc8df1f061abb4d0c107b2b1a794ade8780b3120e681f723fe55a7be586d95ba6" + } + ] + } + }, + "statusCode": 200 +} \ No newline at end of file diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParameters.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParameters.java index 2a8b3eb91bd..e5dba01bf59 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParameters.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParameters.java @@ -34,7 +34,7 @@ public class MiningParameters { public static final int DEFAULT_MAX_OMMERS_DEPTH = 8; - public static final long DEFAULT_POS_BLOCK_CREATION_TIMEOUT_MS = Duration.ofSeconds(7).toMillis(); + public static final long DEFAULT_POS_BLOCK_CREATION_MAX_TIME = Duration.ofSeconds(12).toMillis(); private final Optional
coinbase; private final Optional targetGasLimit; @@ -51,7 +51,7 @@ public class MiningParameters { private final long remoteSealersTimeToLive; private final long powJobTimeToLive; private final int maxOmmerDepth; - private final long posBlockCreationTimeout; + private final long posBlockCreationMaxTime; private MiningParameters( final Address coinbase, @@ -69,7 +69,7 @@ private MiningParameters( final long remoteSealersTimeToLive, final long powJobTimeToLive, final int maxOmmerDepth, - final long posBlockCreationTimeout) { + final long posBlockCreationMaxTime) { this.coinbase = Optional.ofNullable(coinbase); this.targetGasLimit = Optional.ofNullable(targetGasLimit).map(AtomicLong::new); this.minTransactionGasPrice = minTransactionGasPrice; @@ -85,7 +85,7 @@ private MiningParameters( this.remoteSealersTimeToLive = remoteSealersTimeToLive; this.powJobTimeToLive = powJobTimeToLive; this.maxOmmerDepth = maxOmmerDepth; - this.posBlockCreationTimeout = posBlockCreationTimeout; + this.posBlockCreationMaxTime = posBlockCreationMaxTime; } public Optional
getCoinbase() { @@ -148,8 +148,8 @@ public int getMaxOmmerDepth() { return maxOmmerDepth; } - public long getPosBlockCreationTimeout() { - return posBlockCreationTimeout; + public long getPosBlockCreationMaxTime() { + return posBlockCreationMaxTime; } @Override @@ -170,7 +170,7 @@ public boolean equals(final Object o) { && remoteSealersTimeToLive == that.remoteSealersTimeToLive && remoteSealersLimit == that.remoteSealersLimit && powJobTimeToLive == that.powJobTimeToLive - && posBlockCreationTimeout == that.posBlockCreationTimeout; + && posBlockCreationMaxTime == that.posBlockCreationMaxTime; } @Override @@ -189,7 +189,7 @@ public int hashCode() { remoteSealersLimit, remoteSealersTimeToLive, powJobTimeToLive, - posBlockCreationTimeout); + posBlockCreationMaxTime); } @Override @@ -225,8 +225,8 @@ public String toString() { + remoteSealersTimeToLive + ", powJobTimeToLive=" + powJobTimeToLive - + ", posBlockCreationTimeout=" - + posBlockCreationTimeout + + ", posBlockCreationMaxTime=" + + posBlockCreationMaxTime + '}'; } @@ -247,8 +247,7 @@ public static class Builder { private long remoteSealersTimeToLive = DEFAULT_REMOTE_SEALERS_TTL; private long powJobTimeToLive = DEFAULT_POW_JOB_TTL; private int maxOmmerDepth = DEFAULT_MAX_OMMERS_DEPTH; - - private long posBlockCreationTimeout = DEFAULT_POS_BLOCK_CREATION_TIMEOUT_MS; + private long posBlockCreationMaxTime = DEFAULT_POS_BLOCK_CREATION_MAX_TIME; public Builder() { // zero arg @@ -273,7 +272,7 @@ public Builder(final MiningParameters existing) { this.remoteSealersTimeToLive = existing.getRemoteSealersTimeToLive(); this.powJobTimeToLive = existing.getPowJobTimeToLive(); this.maxOmmerDepth = existing.getMaxOmmerDepth(); - this.posBlockCreationTimeout = existing.getPosBlockCreationTimeout(); + this.posBlockCreationMaxTime = existing.getPosBlockCreationMaxTime(); } public Builder coinbase(final Address address) { @@ -351,8 +350,8 @@ public Builder maxOmmerDepth(final int maxOmmerDepth) { return this; } - public Builder posBlockCreationTimeout(final long posBlockCreationTimeoutMillis) { - this.posBlockCreationTimeout = posBlockCreationTimeoutMillis; + public Builder posBlockCreationMaxTime(final long posBlockCreationMaxTime) { + this.posBlockCreationMaxTime = posBlockCreationMaxTime; return this; } @@ -373,7 +372,7 @@ public MiningParameters build() { remoteSealersTimeToLive, powJobTimeToLive, maxOmmerDepth, - posBlockCreationTimeout); + posBlockCreationMaxTime); } } }