From 79c675fb41225446f06d3adf04d1066007e5eb38 Mon Sep 17 00:00:00 2001 From: willhr3 <48725248+willhr3@users.noreply.github.com> Date: Thu, 12 Sep 2019 12:23:28 +0100 Subject: [PATCH] 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 --- .idea/compiler.xml | 8 ++++++ .../identity/PersistentIdentityService.kt | 3 ++- .../migration/node-core.changelog-master.xml | 1 + .../migration/node-core.changelog-v15.xml | 25 +++++++++++++++++++ ...PersistentIdentityMigrationNewTableTest.kt | 1 + .../PersistentIdentityServiceTests.kt | 8 ++++++ 6 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 node/src/main/resources/migration/node-core.changelog-v15.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 2cbf1d59fe..eb676cc51d 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -113,6 +113,8 @@ + + @@ -144,6 +146,7 @@ + @@ -167,6 +170,7 @@ + @@ -215,6 +219,8 @@ + + @@ -230,6 +236,8 @@ + + diff --git a/node/src/main/kotlin/net/corda/node/services/identity/PersistentIdentityService.kt b/node/src/main/kotlin/net/corda/node/services/identity/PersistentIdentityService.kt index bd7aad5d49..d6c06c7d95 100644 --- a/node/src/main/kotlin/net/corda/node/services/identity/PersistentIdentityService.kt +++ b/node/src/main/kotlin/net/corda/node/services/identity/PersistentIdentityService.kt @@ -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 ) diff --git a/node/src/main/resources/migration/node-core.changelog-master.xml b/node/src/main/resources/migration/node-core.changelog-master.xml index bf8e17fb97..58769fd865 100644 --- a/node/src/main/resources/migration/node-core.changelog-master.xml +++ b/node/src/main/resources/migration/node-core.changelog-master.xml @@ -24,6 +24,7 @@ created. --> + diff --git a/node/src/main/resources/migration/node-core.changelog-v15.xml b/node/src/main/resources/migration/node-core.changelog-v15.xml new file mode 100644 index 0000000000..83121186c8 --- /dev/null +++ b/node/src/main/resources/migration/node-core.changelog-v15.xml @@ -0,0 +1,25 @@ + + + + + + + + + SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'node_identities' AND COLUMN_NAME = 'identity_value' + + + + + + + + + + + + + \ No newline at end of file diff --git a/node/src/test/kotlin/net/corda/node/migration/PersistentIdentityMigrationNewTableTest.kt b/node/src/test/kotlin/net/corda/node/migration/PersistentIdentityMigrationNewTableTest.kt index ef5cbdf89f..3f127cd752 100644 --- a/node/src/test/kotlin/net/corda/node/migration/PersistentIdentityMigrationNewTableTest.kt +++ b/node/src/test/kotlin/net/corda/node/migration/PersistentIdentityMigrationNewTableTest.kt @@ -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(), diff --git a/node/src/test/kotlin/net/corda/node/services/identity/PersistentIdentityServiceTests.kt b/node/src/test/kotlin/net/corda/node/services/identity/PersistentIdentityServiceTests.kt index 3fa58e6c5b..3be105ef8d 100644 --- a/node/src/test/kotlin/net/corda/node/services/identity/PersistentIdentityServiceTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/identity/PersistentIdentityServiceTests.kt @@ -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 { val issuerKeyPair = generateKeyPair() val issuer = getTestPartyAndCertificate(x500Name, issuerKeyPair.public)