Network bootstrapper tool: optional configuration setting to specify the minimum plat… (#4005)

* Provide an optional configuration setting to specify the minimum platform version to use in the network params file.

* Leave Cordform signature intact.

* Leave previous Gradle Plugin called signature intact.

* Incorporating feedback from PR review.

* Added minimum platform version validation check.

* Removed final 2 references to "default"

* Added changelog entry.
This commit is contained in:
josecoll 2018-10-03 13:41:52 +01:00 committed by GitHub
parent 7edc18f85d
commit 3110c75847
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 11 deletions

View File

@ -7,6 +7,8 @@ release, see :doc:`upgrade-notes`.
Unreleased
----------
* Introduced new optional network bootstrapper command line option (--minimum-platform-version) to set as a network parameter
* Introduce minimum and target platform version for CorDapps.
* Vault storage of contract state constraints metadata and associated vault query functions to retrieve and sort by constraint type.

View File

@ -162,16 +162,23 @@ internal constructor(private val initSerEnv: Boolean,
}
/** Entry point for the tool */
fun bootstrap(directory: Path, copyCordapps: Boolean) {
fun bootstrap(directory: Path, copyCordapps: Boolean, minimumPlatformVersion: Int) {
require(minimumPlatformVersion <= PLATFORM_VERSION) { "Minimum platform version cannot be greater than $PLATFORM_VERSION" }
// Don't accidently include the bootstrapper jar as a CorDapp!
val bootstrapperJar = javaClass.location.toPath()
val cordappJars = directory.list { paths ->
paths.filter { it.toString().endsWith(".jar") && !it.isSameAs(bootstrapperJar) && it.fileName.toString() != "corda.jar" }.toList()
}
bootstrap(directory, cordappJars, copyCordapps, fromCordform = false)
bootstrap(directory, cordappJars, copyCordapps, fromCordform = false, minimumPlatformVersion = minimumPlatformVersion)
}
private fun bootstrap(directory: Path, cordappJars: List<Path>, copyCordapps: Boolean, fromCordform: Boolean) {
private fun bootstrap(
directory: Path,
cordappJars: List<Path>,
copyCordapps: Boolean,
fromCordform: Boolean,
minimumPlatformVersion: Int = PLATFORM_VERSION
) {
directory.createDirectories()
println("Bootstrapping local test network in $directory")
if (!fromCordform) {
@ -210,7 +217,7 @@ internal constructor(private val initSerEnv: Boolean,
val notaryInfos = gatherNotaryInfos(nodeInfoFiles, configs)
println("Generating contract implementations whitelist")
val newWhitelist = generateWhitelist(existingNetParams, readExcludeWhitelist(directory), cordappJars.filter { !isSigned(it) }.map(contractsJarConverter))
val newNetParams = installNetworkParameters(notaryInfos, newWhitelist, existingNetParams, nodeDirs)
val newNetParams = installNetworkParameters(notaryInfos, newWhitelist, existingNetParams, nodeDirs, minimumPlatformVersion)
if (newNetParams != existingNetParams) {
println("${if (existingNetParams == null) "New" else "Updated"} $newNetParams")
} else {
@ -337,10 +344,13 @@ internal constructor(private val initSerEnv: Boolean,
throw IllegalStateException(msg.toString())
}
private fun installNetworkParameters(notaryInfos: List<NotaryInfo>,
whitelist: Map<String, List<AttachmentId>>,
existingNetParams: NetworkParameters?,
nodeDirs: List<Path>): NetworkParameters {
private fun installNetworkParameters(
notaryInfos: List<NotaryInfo>,
whitelist: Map<String, List<AttachmentId>>,
existingNetParams: NetworkParameters?,
nodeDirs: List<Path>,
minimumPlatformVersion: Int
): NetworkParameters {
// TODO Add config for minimumPlatformVersion, maxMessageSize and maxTransactionSize
val netParams = if (existingNetParams != null) {
if (existingNetParams.whitelistedContractImplementations == whitelist && existingNetParams.notaries == notaryInfos) {
@ -355,7 +365,7 @@ internal constructor(private val initSerEnv: Boolean,
}
} else {
NetworkParameters(
minimumPlatformVersion = 4,
minimumPlatformVersion = minimumPlatformVersion,
notaries = notaryInfos,
modifiedTime = Instant.now(),
maxMessageSize = 10485760,

View File

@ -11,6 +11,7 @@ import net.corda.core.serialization.serialize
import net.corda.node.services.config.NotaryConfig
import net.corda.nodeapi.internal.DEV_ROOT_CA
import net.corda.nodeapi.internal.NODE_INFO_DIRECTORY
import net.corda.nodeapi.internal.PLATFORM_VERSION
import net.corda.nodeapi.internal.SignedNodeInfo
import net.corda.nodeapi.internal.config.parseAs
import net.corda.nodeapi.internal.config.toConfig
@ -217,7 +218,7 @@ class NetworkBootstrapperTest {
private fun bootstrap(copyCordapps: Boolean = true) {
providedCordaJar = (rootDir / "corda.jar").let { if (it.exists()) it.readAll() else null }
bootstrapper.bootstrap(rootDir, copyCordapps)
bootstrapper.bootstrap(rootDir, copyCordapps, PLATFORM_VERSION)
}
private fun createNodeConfFile(nodeDirName: String, config: FakeNodeConfig) {

View File

@ -2,6 +2,7 @@ package net.corda.bootstrapper
import net.corda.cliutils.CordaCliWrapper
import net.corda.cliutils.start
import net.corda.nodeapi.internal.PLATFORM_VERSION
import net.corda.nodeapi.internal.network.NetworkBootstrapper
import picocli.CommandLine.Option
import java.nio.file.Path
@ -24,8 +25,11 @@ class NetworkBootstrapperRunner : CordaCliWrapper("bootstrapper", "Bootstrap a l
@Option(names = ["--no-copy"], description = ["""Don't copy the CorDapp JARs into the nodes' "cordapps" directories."""])
private var noCopy: Boolean = false
@Option(names = ["--minimum-platform-version"], description = ["The minimumPlatformVersion to use in the network-parameters"])
private var minimumPlatformVersion = PLATFORM_VERSION
override fun runProgram(): Int {
NetworkBootstrapper().bootstrap(dir.toAbsolutePath().normalize(), copyCordapps = !noCopy)
NetworkBootstrapper().bootstrap(dir.toAbsolutePath().normalize(), copyCordapps = !noCopy, minimumPlatformVersion = minimumPlatformVersion)
return 0 //exit code
}
}