mirror of
https://github.com/corda/corda.git
synced 2025-02-05 02:29:20 +00:00
Allow the node to cache sandboxed Corda byte-code for reuse.
This commit is contained in:
parent
d0ec1f060a
commit
e570f1f423
@ -29,7 +29,7 @@ snakeYamlVersion=1.19
|
||||
caffeineVersion=2.7.0
|
||||
metricsVersion=4.1.0
|
||||
metricsNewRelicVersion=1.1.1
|
||||
djvmVersion=5.0-SNAPSHOT
|
||||
djvmVersion=1.0-SNAPSHOT
|
||||
openSourceBranch=https://github.com/corda/corda/blob/master
|
||||
openSourceSamplesBranch=https://github.com/corda/samples/blob/master
|
||||
jolokiaAgentVersion=1.6.1
|
||||
|
@ -180,15 +180,15 @@ dependencies {
|
||||
compile "com.typesafe:config:$typesafe_config_version"
|
||||
|
||||
// Sandbox for deterministic contract verification
|
||||
compile "net.corda:corda-djvm:$djvm_version"
|
||||
compile "net.corda:corda-djvm-serialization:$djvm_version"
|
||||
compile "net.corda.djvm:corda-djvm:$djvm_version"
|
||||
compile "net.corda.djvm:corda-djvm-serialization:$djvm_version"
|
||||
compile(project(':node:djvm')) {
|
||||
transitive = false
|
||||
}
|
||||
jdkRt "net.corda:deterministic-rt:latest.integration"
|
||||
deterministic project(path: ':core-deterministic', configuration: 'deterministicArtifacts')
|
||||
deterministic project(path: ':serialization-deterministic', configuration: 'deterministicArtifacts')
|
||||
deterministic("net.corda:corda-djvm-deserializers:$djvm_version") {
|
||||
deterministic("net.corda.djvm:corda-djvm-deserializers:$djvm_version") {
|
||||
transitive = false
|
||||
}
|
||||
deterministic(project(':node:djvm')) {
|
||||
|
@ -9,7 +9,6 @@ import net.corda.core.internal.*
|
||||
import net.corda.core.serialization.serialize
|
||||
import net.corda.core.transactions.LedgerTransaction
|
||||
import net.corda.djvm.SandboxConfiguration
|
||||
import net.corda.djvm.analysis.AnalysisConfiguration
|
||||
import net.corda.djvm.execution.*
|
||||
import net.corda.djvm.messages.Message
|
||||
import net.corda.djvm.source.ClassSource
|
||||
@ -18,17 +17,11 @@ import net.corda.node.djvm.LtxFactory
|
||||
class DeterministicVerifier(
|
||||
ltx: LedgerTransaction,
|
||||
transactionClassLoader: ClassLoader,
|
||||
private val analysisConfiguration: AnalysisConfiguration
|
||||
private val sandboxConfiguration: SandboxConfiguration
|
||||
) : Verifier(ltx, transactionClassLoader) {
|
||||
|
||||
override fun verifyContracts() {
|
||||
val configuration = SandboxConfiguration.createFor(
|
||||
analysisConfiguration = analysisConfiguration,
|
||||
profile = ExecutionProfile.DEFAULT,
|
||||
enableTracing = false
|
||||
)
|
||||
|
||||
val result = IsolatedTask(ltx.id.toString(), configuration).run {
|
||||
val result = IsolatedTask(ltx.id.toString(), sandboxConfiguration).run {
|
||||
val taskFactory = classLoader.createRawTaskFactory()
|
||||
val sandboxBasicInput = classLoader.createBasicInput()
|
||||
|
||||
@ -98,7 +91,6 @@ class DeterministicVerifier(
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun close() {
|
||||
// analysisConfiguration.closeAll()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,10 @@ import net.corda.core.serialization.CordaSerializable
|
||||
import net.corda.core.serialization.DeprecatedConstructorForDeserialization
|
||||
import net.corda.core.serialization.SingletonSerializeAsToken
|
||||
import net.corda.core.transactions.LedgerTransaction
|
||||
import net.corda.djvm.SandboxConfiguration
|
||||
import net.corda.djvm.analysis.AnalysisConfiguration
|
||||
import net.corda.djvm.analysis.Whitelist
|
||||
import net.corda.djvm.execution.ExecutionProfile
|
||||
import net.corda.djvm.source.ApiSource
|
||||
import net.corda.djvm.source.UserPathSource
|
||||
import net.corda.djvm.source.UserSource
|
||||
@ -20,15 +22,10 @@ class DeterministicVerifierFactoryService(
|
||||
private val bootstrapSource: ApiSource,
|
||||
private val cordaSource: UserSource?
|
||||
) : SingletonSerializeAsToken(), AutoCloseable {
|
||||
private val baseSandboxConfiguration: SandboxConfiguration
|
||||
|
||||
fun specialise(ltx: LedgerTransaction, classLoader: ClassLoader): Verifier {
|
||||
return (classLoader as? URLClassLoader)?.run {
|
||||
DeterministicVerifier(ltx, classLoader, createSandbox(classLoader.urLs))
|
||||
} ?: BasicVerifier(ltx, classLoader)
|
||||
}
|
||||
|
||||
private fun createSandbox(userSource: Array<URL>): AnalysisConfiguration {
|
||||
return AnalysisConfiguration.createRoot(
|
||||
init {
|
||||
val baseAnalysisConfiguration = AnalysisConfiguration.createRoot(
|
||||
userSource = cordaSource!!,
|
||||
whitelist = Whitelist.MINIMAL,
|
||||
visibleAnnotations = setOf(
|
||||
@ -37,11 +34,23 @@ class DeterministicVerifierFactoryService(
|
||||
DeprecatedConstructorForDeserialization::class.java
|
||||
),
|
||||
bootstrapSource = bootstrapSource
|
||||
).createChild(
|
||||
userSource = UserPathSource(userSource),
|
||||
newMinimumSeverityLevel = null,
|
||||
visibleAnnotations = emptySet()
|
||||
)
|
||||
|
||||
baseSandboxConfiguration = SandboxConfiguration.createFor(
|
||||
analysisConfiguration = baseAnalysisConfiguration,
|
||||
profile = ExecutionProfile.DEFAULT,
|
||||
enableTracing = false
|
||||
)
|
||||
}
|
||||
|
||||
fun specialise(ltx: LedgerTransaction, classLoader: ClassLoader): Verifier {
|
||||
return (classLoader as? URLClassLoader)?.run {
|
||||
DeterministicVerifier(ltx, classLoader, createSandbox(classLoader.urLs))
|
||||
} ?: BasicVerifier(ltx, classLoader)
|
||||
}
|
||||
|
||||
private fun createSandbox(userSource: Array<URL>): SandboxConfiguration {
|
||||
return baseSandboxConfiguration.createChild(UserPathSource(userSource))
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user