CORDA-3200 Fix postgres oid/ bytea column issue (#5465)

* CORDA-3200 Add postgres specific migration to change from @Lob to @Type(type = corda-blob)

* CORDA-3200 Remove unwanted changes

* CORDA-3200 Change column length to 64000 for long cert chains
This commit is contained in:
willhr3 2019-09-12 12:23:28 +01:00 committed by Stefano Franz
parent 81a6a9ecba
commit 79c675fb41
6 changed files with 45 additions and 1 deletions

8
.idea/compiler.xml generated
View File

@ -113,6 +113,8 @@
<module name="corda-project.example-code.test" target="1.8" />
<module name="corda-project.experimental.avalanche.main" target="1.8" />
<module name="corda-project.experimental.avalanche.test" target="1.8" />
<module name="corda-project.experimental.blobwriter.main" target="1.8" />
<module name="corda-project.experimental.blobwriter.test" target="1.8" />
<module name="corda-project.experimental.corda-utils.integrationTest" target="1.8" />
<module name="corda-project.experimental.corda-utils.main" target="1.8" />
<module name="corda-project.experimental.corda-utils.test" target="1.8" />
@ -144,6 +146,7 @@
<module name="corda-project.node.capsule.test" target="1.8" />
<module name="corda-project.node.integrationTest" target="1.8" />
<module name="corda-project.node.main" target="1.8" />
<module name="corda-project.node.slowIntegrationTest" target="1.8" />
<module name="corda-project.node.test" target="1.8" />
<module name="corda-project.samples.attachment-demo.contracts.main" target="1.8" />
<module name="corda-project.samples.attachment-demo.contracts.test" target="1.8" />
@ -167,6 +170,7 @@
<module name="corda-project.samples.irs-demo.cordapp.workflows-irs.test" target="1.8" />
<module name="corda-project.samples.irs-demo.integrationTest" target="1.8" />
<module name="corda-project.samples.irs-demo.main" target="1.8" />
<module name="corda-project.samples.irs-demo.slowIntegrationTest" target="1.8" />
<module name="corda-project.samples.irs-demo.systemTest" target="1.8" />
<module name="corda-project.samples.irs-demo.test" target="1.8" />
<module name="corda-project.samples.irs-demo.web.main" target="1.8" />
@ -215,6 +219,8 @@
<module name="corda-project.tools.blobinspector.test" target="1.8" />
<module name="corda-project.tools.bootstrapper.main" target="1.8" />
<module name="corda-project.tools.bootstrapper.test" target="1.8" />
<module name="corda-project.tools.checkpoint-agent.main" target="1.8" />
<module name="corda-project.tools.checkpoint-agent.test" target="1.8" />
<module name="corda-project.tools.cliutils.main" target="1.8" />
<module name="corda-project.tools.cliutils.test" target="1.8" />
<module name="corda-project.tools.demobench.main" target="1.8" />
@ -230,6 +236,8 @@
<module name="corda-project.tools.main" target="1.8" />
<module name="corda-project.tools.network-bootstrapper.main" target="1.8" />
<module name="corda-project.tools.network-bootstrapper.test" target="1.8" />
<module name="corda-project.tools.network-builder.main" target="1.8" />
<module name="corda-project.tools.network-builder.test" target="1.8" />
<module name="corda-project.tools.shell-cli.main" target="1.8" />
<module name="corda-project.tools.shell-cli.test" target="1.8" />
<module name="corda-project.tools.shell.integrationTest" target="1.8" />

View File

@ -18,6 +18,7 @@ import net.corda.nodeapi.internal.crypto.X509Utilities
import net.corda.nodeapi.internal.crypto.x509Certificates
import net.corda.nodeapi.internal.persistence.CordaPersistence
import net.corda.nodeapi.internal.persistence.NODE_DATABASE_PREFIX
import org.hibernate.annotations.Type
import org.hibernate.internal.util.collections.ArrayHelper.EMPTY_BYTE_ARRAY
import java.security.InvalidAlgorithmParameterException
import java.security.PublicKey
@ -107,7 +108,7 @@ class PersistentIdentityService(cacheFactory: NamedCacheFactory) : SingletonSeri
@Column(name = PK_HASH_COLUMN_NAME, length = MAX_HASH_HEX_SIZE, nullable = false)
var publicKeyHash: String = "",
@Lob
@Type(type = "corda-blob")
@Column(name = IDENTITY_COLUMN_NAME, nullable = false)
var identity: ByteArray = EMPTY_BYTE_ARRAY
)

View File

@ -24,6 +24,7 @@
created. -->
<include file="migration/node-core.changelog-v13.xml"/>
<include file="migration/node-core.changelog-v14-data.xml"/>
<include file="migration/node-core.changelog-v15.xml"/>
<!-- This must run after node-core.changelog-init.xml, to prevent database columns being created twice. -->
<include file="migration/vault-schema.changelog-v9.xml"/>
</databaseChangeLog>

View File

@ -0,0 +1,25 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<changeSet author="R3.Corda" id="modify identity_value column type" dbms="postgresql">
<preConditions onFail="MARK_RAN">
<not>
<sqlCheck expectedResult="bytea">
SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'node_identities' AND COLUMN_NAME = 'identity_value'
</sqlCheck>
</not>
</preConditions>
<dropColumn tableName="node_identities" columnName="identity_value"/>
<addColumn tableName="node_identities">
<column name="identity_value" type="varbinary(64000)">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>
</databaseChangeLog>

View File

@ -59,6 +59,7 @@ class PersistentIdentityMigrationNewTableTest{
fun setUp() {
val identityService = makeTestIdentityService(PersistentIdentityMigrationNewTableTest.dummyNotary.identity, BOB_IDENTITY, ALICE_IDENTITY)
notaryServices = MockServices(listOf("net.corda.finance.contracts"), dummyNotary, identityService, dummyCashIssuer.keyPair, BOC_KEY)
// Runs migration tasks
cordaDB = configureDatabase(
MockServices.makeTestDataSourceProperties(),

View File

@ -7,6 +7,7 @@ import net.corda.core.identity.CordaX500Name
import net.corda.core.identity.Party
import net.corda.core.identity.PartyAndCertificate
import net.corda.core.node.services.UnknownAnonymousPartyException
import net.corda.core.serialization.serialize
import net.corda.nodeapi.internal.crypto.CertificateType
import net.corda.nodeapi.internal.crypto.X509Utilities
import net.corda.nodeapi.internal.crypto.x509Certificates
@ -268,6 +269,13 @@ class PersistentIdentityServiceTests {
}
}
@Test
fun `P&C size`() {
val (_, anonymousAlice) = createConfidentialIdentity(ALICE.name)
val serializedCert = anonymousAlice.serialize()
println(serializedCert)
}
private fun createConfidentialIdentity(x500Name: CordaX500Name): Pair<PartyAndCertificate, PartyAndCertificate> {
val issuerKeyPair = generateKeyPair()
val issuer = getTestPartyAndCertificate(x500Name, issuerKeyPair.public)