From 4672c3a13cb584d5c8d33021dda8cf84dbf9b694 Mon Sep 17 00:00:00 2001 From: bpaunescu Date: Wed, 25 Sep 2019 10:34:26 +0100 Subject: [PATCH] CORDA-3240: optional node.conf property not recognized when overridden (#5505) * CORDA-3240: optional node.conf property not recognized when overridden * CORDA-3240: address detekt issues * [NOTICK]: undo incorrectly commmented out include --- .../kotlin/net/corda/node/internal/AbstractNode.kt | 2 +- .../corda/node/services/config/NodeConfiguration.kt | 2 +- .../node/services/config/NodeConfigurationImpl.kt | 3 ++- .../services/config/schema/v1/ConfigSections.kt | 13 +++++++++++++ .../config/schema/v1/V1NodeConfigurationSpec.kt | 6 +++++- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt b/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt index d8a5c90132..a37a452c7f 100644 --- a/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt +++ b/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt @@ -375,7 +375,7 @@ abstract class AbstractNode(val configuration: NodeConfiguration, signedNodeInfo, netParams, keyManagementService, - configuration.networkParameterAcceptanceSettings) + configuration.networkParameterAcceptanceSettings!!) try { startMessagingService(rpcOps, nodeInfo, myNotaryIdentity, netParams) } catch (e: Exception) { diff --git a/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt b/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt index c1515430e8..c6c7ebe54d 100644 --- a/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt +++ b/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt @@ -81,7 +81,7 @@ interface NodeConfiguration { val cordappSignerKeyFingerprintBlacklist: List - val networkParameterAcceptanceSettings: NetworkParameterAcceptanceSettings + val networkParameterAcceptanceSettings: NetworkParameterAcceptanceSettings? val blacklistedAttachmentSigningKeys: List diff --git a/node/src/main/kotlin/net/corda/node/services/config/NodeConfigurationImpl.kt b/node/src/main/kotlin/net/corda/node/services/config/NodeConfigurationImpl.kt index 488bda6bd1..a3dbe02f3d 100644 --- a/node/src/main/kotlin/net/corda/node/services/config/NodeConfigurationImpl.kt +++ b/node/src/main/kotlin/net/corda/node/services/config/NodeConfigurationImpl.kt @@ -75,7 +75,8 @@ data class NodeConfigurationImpl( override val jmxReporterType: JmxReporterType? = Defaults.jmxReporterType, override val flowOverrides: FlowOverrideConfig?, override val cordappSignerKeyFingerprintBlacklist: List = Defaults.cordappSignerKeyFingerprintBlacklist, - override val networkParameterAcceptanceSettings: NetworkParameterAcceptanceSettings = Defaults.networkParameterAcceptanceSettings, + override val networkParameterAcceptanceSettings: NetworkParameterAcceptanceSettings? = + Defaults.networkParameterAcceptanceSettings, override val blacklistedAttachmentSigningKeys: List = Defaults.blacklistedAttachmentSigningKeys ) : NodeConfiguration { internal object Defaults { diff --git a/node/src/main/kotlin/net/corda/node/services/config/schema/v1/ConfigSections.kt b/node/src/main/kotlin/net/corda/node/services/config/schema/v1/ConfigSections.kt index 882a254196..81fc40ff66 100644 --- a/node/src/main/kotlin/net/corda/node/services/config/schema/v1/ConfigSections.kt +++ b/node/src/main/kotlin/net/corda/node/services/config/schema/v1/ConfigSections.kt @@ -21,6 +21,7 @@ import net.corda.node.services.config.DevModeOptions import net.corda.node.services.config.FlowOverride import net.corda.node.services.config.FlowOverrideConfig import net.corda.node.services.config.FlowTimeoutConfiguration +import net.corda.node.services.config.NetworkParameterAcceptanceSettings import net.corda.node.services.config.NetworkServicesConfig import net.corda.node.services.config.NodeH2Settings import net.corda.node.services.config.NodeRpcSettings @@ -143,6 +144,18 @@ internal object NetworkServicesConfigSpec : Configuration.Specification("NetworkParameterAcceptanceSettings") { + private val autoAcceptEnabled by boolean().optional().withDefaultValue(true) + private val excludedAutoAcceptableParameters by string().listOrEmpty() + override fun parseValid(configuration: Config): Valid { + return valid(NetworkParameterAcceptanceSettings(configuration[autoAcceptEnabled], + configuration[excludedAutoAcceptableParameters].toSet()) + ) + } +} + + @Suppress("DEPRECATION") internal object CertChainPolicyConfigSpec : Configuration.Specification("CertChainPolicyConfig") { private val role by string() diff --git a/node/src/main/kotlin/net/corda/node/services/config/schema/v1/V1NodeConfigurationSpec.kt b/node/src/main/kotlin/net/corda/node/services/config/schema/v1/V1NodeConfigurationSpec.kt index 5c9bdf4ac1..32feeb73e0 100644 --- a/node/src/main/kotlin/net/corda/node/services/config/schema/v1/V1NodeConfigurationSpec.kt +++ b/node/src/main/kotlin/net/corda/node/services/config/schema/v1/V1NodeConfigurationSpec.kt @@ -58,6 +58,9 @@ internal object V1NodeConfigurationSpec : Configuration.Specification