From a888d78b42b8dabec888b99f659cbb23ac336dcf Mon Sep 17 00:00:00 2001 From: Katarzyna Streich Date: Fri, 23 Mar 2018 17:01:46 +0000 Subject: [PATCH] Fix serialization on network map startup (#598) Fix serialization on network-management startup Minor documentation fixes --- network-management/README.md | 12 ++++++++++-- .../corda/networkmanage/doorman/DoormanArgsParser.kt | 2 +- .../com/r3/corda/networkmanage/doorman/Main.kt | 3 +-- .../networkmanage/doorman/NetworkManagementServer.kt | 6 +++++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/network-management/README.md b/network-management/README.md index 7c84371fb7..05e6df5f2a 100644 --- a/network-management/README.md +++ b/network-management/README.md @@ -245,7 +245,7 @@ Run the following SQL script to archive the node info table (change the timestam The initial network parameters can be subsequently changed through an update process. However, these changes must first be advertised to the entire network to allow nodes time to agree to the changes. -The server needs to be shutdown and started with the same `set-network-parameters` as before but this time the network +The server needs to be shutdown and started with the same `set-network-parameters` flag as before but this time the network parameters file must have `parametersUpdate` config block: parametersUpdate { @@ -268,10 +268,18 @@ When the time for switching the parameters comes, doorman should be restarted ag java -jar doorman-.jar --flag-day ``` -This will switch the parameters that were previously advertised as an update to be the current ones in the network map. +This will switch the parameters that were previously advertised as an update to be the current ones in the network map, +however the new network parameters won't be active until the new network map is signed (either by HSM or by local signer). All nodes in the network need to restart to apply the new parameters. Any node which has not accepted the new parameters will fail to start. +It is possible to cancel the previously scheduled updated. To do so simply run: +``` +java -jar doorman-.jar --cancel-update +``` + +The network map will continue to advertise the cancelled update until the new network map is signed. + # Private Network Map The private network is a tactical solution to provide temporary privacy to the initial network map. diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/DoormanArgsParser.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/DoormanArgsParser.kt index f221cd3228..6c60c07bf3 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/DoormanArgsParser.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/DoormanArgsParser.kt @@ -32,7 +32,7 @@ class DoormanArgsParser { .withRequiredArg() .withValuesConvertedBy(PathConverter(PathProperties.FILE_EXISTING)) private val flagDayArg = optionParser.accepts("flag-day", "Roll over the scheduled network parameters to be the current.") - private val cancelUpdateArg = optionParser.accepts("cancel-network-parameters-update", "Cancel the scheduled update of the network parameters.") + private val cancelUpdateArg = optionParser.accepts("cancel-update", "Cancel the scheduled update of the network parameters.") private val trustStorePasswordArg = optionParser .accepts("trust-store-password", "Password for the generated network root trust store. Only applicable when operating in ${Mode.ROOT_KEYGEN} mode.") .withRequiredArg() diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/Main.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/Main.kt index e992c08d12..45668cc6de 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/Main.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/Main.kt @@ -26,6 +26,7 @@ fun main(args: Array) { println("Version: ${Manifests.read("Doorman-Version")}") } + initialiseSerialization() val cmdLineOptions = try { DoormanArgsParser().parse(*args) } catch (e: ShowHelpException) { @@ -81,8 +82,6 @@ private fun caKeyGenMode(config: NetworkManagementServerConfig) { } private fun doormanMode(cmdLineOptions: DoormanCmdLineOptions, config: NetworkManagementServerConfig) { - initialiseSerialization() - val networkManagementServer = NetworkManagementServer(config.dataSourceProperties, config.database) if (cmdLineOptions.networkParametersCmd == null) { diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/NetworkManagementServer.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/NetworkManagementServer.kt index cfa57bc569..ed079f3ce5 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/NetworkManagementServer.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/NetworkManagementServer.kt @@ -58,7 +58,7 @@ class NetworkManagementServer(dataSourceProperties: Properties, databaseConfig: val localNetworkMapSigner = signer?.let { NetworkMapSigner(networkMapStorage, it) } val latestParameters = networkMapStorage.getLatestNetworkParameters()?.networkParameters ?: throw IllegalStateException("No network parameters were found. Please upload new network parameters before starting network map service") - logger.info("Starting network map service with network parameters: $latestParameters") + logger.info("Starting network map service with latest network parameters: $latestParameters") localNetworkMapSigner?.signAndPersistNetworkParameters(latestParameters) if (localNetworkMapSigner != null) { @@ -204,6 +204,7 @@ class NetworkManagementServer(dataSourceProperties: Properties, databaseConfig: val initialNetParams = setNetParams.toNetworkParameters(modifiedTime = Instant.now(), epoch = 1) logger.info("Saving initial network parameters to be signed:\n$initialNetParams") networkMapStorage.saveNetworkParameters(initialNetParams, null) + println("Saved initial network parameters to be signed:\n$initialNetParams") } else { val parametersUpdate = requireNotNull(setNetParams.parametersUpdate) { "'parametersUpdate' not specified in network parameters file but there is already an active set of network parameters" @@ -228,6 +229,7 @@ class NetworkManagementServer(dataSourceProperties: Properties, databaseConfig: networkMapStorage.saveNewParametersUpdate(newNetParams, parametersUpdate.description, parametersUpdate.updateDeadline) logger.info("Update enabled") + println("Enabled update to network parameters:\n$newNetParams\n$parametersUpdate") } } @@ -254,6 +256,7 @@ class NetworkManagementServer(dataSourceProperties: Properties, databaseConfig: logger.info("Flag day has occurred, however the new network parameters won't be active until the new network map is signed.\n" + "Switching from: $activeNetParams\nTo: ${latestNetParamsEntity.networkParameters}") networkMapStorage.setFlagDay(SecureHash.parse(parametersUpdate.networkParameters.hash)) + println("Set the flag day") } private fun handleCancelUpdate() { @@ -265,5 +268,6 @@ class NetworkManagementServer(dataSourceProperties: Properties, databaseConfig: // We leave parameters from that update in the database, for auditing reasons networkMapStorage.clearParametersUpdates() } + println("Done with cancel update") } }