Disable hash constraints using system property.

This commit is contained in:
josecoll 2019-02-14 13:35:15 +00:00 committed by Mike Hearn
parent 060bbb0a9d
commit e252401169
2 changed files with 9 additions and 3 deletions

View File

@ -4,7 +4,6 @@ import net.corda.core.DeleteForDJVM
import net.corda.core.concurrent.CordaFuture
import net.corda.core.contracts.*
import net.corda.core.contracts.TransactionVerificationException.TransactionContractConflictException
import net.corda.core.internal.cordapp.CordappImpl
import net.corda.core.internal.rules.StateContractValidationEnforcementRule
import net.corda.core.transactions.LedgerTransaction
import net.corda.core.utilities.contextLogger
@ -37,6 +36,7 @@ class Verifier(val ltx: LedgerTransaction,
companion object {
private val logger = contextLogger()
private val disableHashConstraints = System.getProperty("net.corda.node.internal.Verifier.disableHashConstraints")?.toBoolean() ?: false
}
/**
@ -339,11 +339,12 @@ class Verifier(val ltx: LedgerTransaction,
val constraintAttachment = AttachmentWithContext(contractAttachment, contract, ltx.networkParameters!!.whitelistedContractImplementations)
if (!constraint.isSatisfiedBy(constraintAttachment)) {
if (disableHashConstraints && constraint is HashAttachmentConstraint)
logger.warn("Skipping hash constraints verification.")
else if (!constraint.isSatisfiedBy(constraintAttachment))
throw TransactionVerificationException.ContractConstraintRejection(ltx.id, contract)
}
}
}
/**
* Check the transaction is contract-valid by running the verify() for each input and output state contract.

View File

@ -177,6 +177,11 @@ open class NodeStartup : NodeStartupLogging {
logger.info("The Corda node is running in production mode. If this is a developer environment you can set 'devMode=true' in the node.conf file.")
}
val disableHashConstraints = System.getProperty("net.corda.node.internal.Verifier.disableHashConstraints")?.toBoolean() ?: false
if (disableHashConstraints) {
Node.printWarning("Hash constraints checking has been disabled by the node operator.")
}
val nodeInfo = node.start()
val loadedCodapps = node.services.cordappProvider.cordapps.filter { it.isLoaded }
logLoadedCorDapps(loadedCodapps)