From c0d6d43306a97c207ff0c3afd25079a6b2b25385 Mon Sep 17 00:00:00 2001 From: Chen Kai <281165273grape@gmail.com> Date: Thu, 7 Dec 2023 12:25:42 +0800 Subject: [PATCH] fix:fix p2p network start bug Signed-off-by: Chen Kai <281165273grape@gmail.com> --- hildr-node/build.gradle | 2 +- .../src/main/java/io/optimism/driver/Driver.java | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/hildr-node/build.gradle b/hildr-node/build.gradle index b1ef22a4..6976ce3f 100644 --- a/hildr-node/build.gradle +++ b/hildr-node/build.gradle @@ -23,7 +23,7 @@ plugins { } group 'me.grapebaba' -version '0.2.0' +version '0.2.1' repositories { // Use Maven Central for resolving dependencies. diff --git a/hildr-node/src/main/java/io/optimism/driver/Driver.java b/hildr-node/src/main/java/io/optimism/driver/Driver.java index 0d65a535..3ccb4b4a 100644 --- a/hildr-node/src/main/java/io/optimism/driver/Driver.java +++ b/hildr-node/src/main/java/io/optimism/driver/Driver.java @@ -113,7 +113,9 @@ public class Driver extends AbstractExecutionThreadService { private RollupConfigResult cachedRollConfig; - private OpStackNetwork opStackNetwork; + private final OpStackNetwork opStackNetwork; + + private volatile boolean isP2PNetworkStarted; /** * Instantiates a new Driver. @@ -127,7 +129,6 @@ public class Driver extends AbstractExecutionThreadService { * @param latch the close notifier * @param config the chain config * @param opStackNetwork the op stack network - * */ @SuppressWarnings("preview") public Driver( @@ -371,11 +372,10 @@ protected void shutDown() { LOGGER.info("engineDriver shut down."); this.rpcServer.stop(); LOGGER.info("driver stopped."); - if (this.opStackNetwork != null) { + if (this.opStackNetwork != null && this.isP2PNetworkStarted) { this.opStackNetwork.stop(); LOGGER.info("opStackNetwork stopped."); } - this.tryStartNetwork(); } @Override @@ -414,6 +414,8 @@ private void advance() throws InterruptedException, ExecutionException { } this.updateFinalized(); this.updateMetrics(); + + this.tryStartNetwork(); } private void advanceSafeHead() throws ExecutionException, InterruptedException { @@ -563,7 +565,7 @@ private boolean synced() { } private void tryStartNetwork() { - if (this.synced() && this.opStackNetwork != null) { + if (this.synced() && this.opStackNetwork != null && !this.isP2PNetworkStarted) { this.opStackNetwork.start(); } }