Avoid a cyclic reference while printing EngineExchangeTransitionConfigurationParameter (#4357)

* avoids a cyclic reference while printing EngineExchangeTransitionConfigurationParameter

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
pull/4527/head
Daniel Lehrner 2 years ago committed by GitHub
parent 32125fb690
commit 5dec71c925
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 15
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfiguration.java
  3. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EngineExchangeTransitionConfigurationParameter.java

@ -15,6 +15,7 @@
### 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)
- Avoid a cyclic reference while printing EngineExchangeTransitionConfigurationParameter [#4357](https://github.com/hyperledger/besu/pull/4357)
### Download Links

@ -30,9 +30,12 @@ import org.hyperledger.besu.ethereum.core.BlockHeader;
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<ObjectMapper> mapperSupplier = Suppliers.memoize(ObjectMapper::new);
public EngineExchangeTransitionConfiguration(
final Vertx vertx,
final ProtocolContext protocolContext,
@ -69,7 +74,13 @@ public class EngineExchangeTransitionConfiguration extends ExecutionEngineJsonRp
traceLambda(
LOG,
"received transitionConfiguration: {}",
() -> Json.encodePrettily(remoteTransitionConfiguration));
() -> {
try {
return mapperSupplier.get().writeValueAsString(remoteTransitionConfiguration);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
});
final Optional<BlockHeader> maybeTerminalPoWBlockHeader =
mergeContextOptional.flatMap(MergeContext::getTerminalPoWBlock);

@ -39,10 +39,20 @@ public class EngineExchangeTransitionConfigurationParameter {
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;
}

Loading…
Cancel
Save