Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R3SOL-368 Move ledger flow code from components into a new library #6353

Merged

Conversation

williamvigorr3
Copy link
Contributor

@williamvigorr3 williamvigorr3 commented Oct 1, 2024

Put ledger flow code into a new library. Uncoupled the new libraries dependencies and transitive dependencies from the avro schema. Pulling out code where needed into new modules (if there isn't a sensible place).

@williamvigorr3 williamvigorr3 force-pushed the WillV/R3SOL-368-Extract-Ledger-Lib branch from ac9b06e to c36fb62 Compare October 1, 2024 08:14
@corda-jenkins-ci02
Copy link
Contributor

corda-jenkins-ci02 bot commented Oct 1, 2024

Jenkins build for PR 6353 build 62

Build Successful:
Jar artifact version produced by this PR: 5.3.0.0-alpha-1729778193720
Helm chart version produced by this PR: 5.3.0-alpha.1729778193720
Helm chart pushed to: oci://corda-os-docker-dev.software.r3.com/helm-charts/pr-6353/corda
Helm chart Polaris score: 82

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do all those impl packages now need package-info files? Exporting an impl is usually a smell...

Copy link
Contributor Author

@williamvigorr3 williamvigorr3 Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I don't export these then I get the following error (so it looks like the exports are needed by the ledger flow tests):

> Task :components:ledger:ledger-utxo-flow:resolve FAILED
Resolution failed. Capabilities satisfying the following requirements could not be found:
    [<<INITIAL>>]
      ⇒ osgi.identity: (osgi.identity=ledger-utxo-flow-tests)
          ⇒ [ledger-utxo-flow-tests version=5.3.0.0-SNAPSHOT]
              ⇒ osgi.wiring.package: (osgi.wiring.package=net.corda.ledger.lib.utxo.flow.impl.timewindow)

These were exported in their original location (except libs/ledger-lib-utxo-flow/src/main/java/net/corda/ledger/lib/utxo/flow/impl/transaction/factory/impl/package-info.java I'll try and work out why I needed to export that).

For example:

https://github.com/corda/corda-runtime-os/blob/release/os/5.3/components/ledger/ledger-utxo-flow/src/main/java/net/corda/ledger/utxo/flow/impl/persistence/package-info.java

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iirc, when we exported an impl it was to get an integration test to work or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't get the tests to resolve without libs/ledger-lib-utxo-flow/src/main/java/net/corda/ledger/lib/utxo/flow/impl/transaction/factory/impl/package-info.java (as well).

@lankydan
Copy link
Contributor

lankydan commented Oct 8, 2024

Nothing has jumped out to me as being wrong when i reviewed the diff, will take a closer look though.

@williamvigorr3 williamvigorr3 marked this pull request as ready for review October 14, 2024 12:32
@williamvigorr3 williamvigorr3 requested review from a team as code owners October 14, 2024 12:32
wzur-r3
wzur-r3 previously approved these changes Oct 15, 2024
Copy link
Contributor

@wzur-r3 wzur-r3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gradle configuration changes LGTM

Copy link
Contributor

@blsemo blsemo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me, just the one question...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question - shouldn't the OsgiImpl be in a different module, so that we can pull in the non-OSGi version to the new project?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this offline but concluded the annotations are Okay as corda-dlt will ignore them and do not use OSGi for dependancy injection.

@williamvigorr3 williamvigorr3 requested a review from a team as a code owner October 17, 2024 10:23
@williamvigorr3 williamvigorr3 changed the base branch from release/os/5.3 to feature/ledger-lib October 23, 2024 08:52
lankydan
lankydan previously approved these changes Oct 23, 2024
@lankydan
Copy link
Contributor

Remember to target the feature branch.

@williamvigorr3 williamvigorr3 changed the base branch from feature/ledger-lib to feature/ledger-library October 23, 2024 12:02
@williamvigorr3 williamvigorr3 dismissed lankydan’s stale review October 23, 2024 12:02

The base branch was changed.

@@ -39,6 +38,7 @@ import java.net.http.HttpResponse
import java.time.Duration
import java.time.Instant
import java.util.UUID
import net.corda.crypto.core.avro.toAvro
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how'd this pass detekt with this import here 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe detekt isn't running in the smokeTest dir.

lankydan
lankydan previously approved these changes Oct 24, 2024
Comment on lines 38 to 39
fun AvroSecureHash.toCorda(): SecureHash =
SecureHashImpl(this.algorithm, this.bytes.array())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be possible to have the toAvro/toCorda functions defined somewhere and reuse them? They seem to be defined an awful lot of times...
Maybe not one central place, but even reducing the numbers would be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some got missed during refactoring. I fixed this now.

@@ -22,6 +22,7 @@ import org.osgi.service.component.annotations.ReferenceScope.PROTOTYPE_REQUIRED
import org.osgi.service.component.annotations.ServiceScope
import java.io.InputStream

// I think the merkle tree code only has a dep on other crypto modules for this and secure hash impl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this comment stay here? That looks like a note for work in progress?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed this.

Comment on lines +9 to +13
fun AvroSecureHash.toCorda(): SecureHash =
SecureHashImpl(this.algorithm, this.bytes.array())

fun SecureHash.toAvro(): AvroSecureHash =
AvroSecureHash(this.algorithm, ByteBuffer.wrap(bytes))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you've got a central definition here, why not use that everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed this now.

description 'Common crypto implementation'

dependencies {
// compileOnly "org.osgi:org.osgi.service.component.annotations"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented out stuff, please!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fixed.

@@ -110,7 +111,7 @@ fun SignatureSpec.toWire(serializer: AlgorithmParameterSpecEncodingService): Cry
else -> CryptoSignatureSpec(signatureName, null, null)
}.also {
CordaMetrics.Metric.Crypto.SignatureSpecTimer.builder()
.withTag(CordaMetrics.Tag.OperationName, TO_WIRE_OPERATION_NAME)
.withTag(CordaMetrics.Tag.OperationName, net.corda.crypto.impl.utils.TO_WIRE_OPERATION_NAME)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the fully qualified name required here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed this. I think Intelij sometimes does this on refactor.


implementation project(':libs:ledger:ledger-common-data')
implementation project(':libs:crypto:crypto-core')
implementation project(':libs:serialization:serialization-amqp-api')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we depend on this in the new project? If yes, then AMQP would not be a comfortable dependency...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just amqp-api. So I think it's Okay.

./gradlew :libs:serialization:serialization-amqp-api:dependencies --configuration runTimeClassPath
runtimeClasspath - Runtime classpath of null/main.
+--- net.corda:corda-api:5.3.0.16-beta+ -> 5.3.0.16-beta-1729750087895
|    +--- net.corda:corda-application:5.3.0.16-beta-1729750087895 (c)
|    +--- org.jetbrains.kotlin:kotlin-osgi-bundle:1.8.21 (c)
|    +--- javax.persistence:javax.persistence-api:2.2 (c)
|    +--- net.corda:corda-base:5.3.0.16-beta-1729750087895 (c)
|    +--- net.corda:corda-crypto:5.3.0.16-beta-1729750087895 (c)
|    +--- net.corda:corda-membership:5.3.0.16-beta-1729750087895 (c)
|    +--- net.corda:corda-serialization:5.3.0.16-beta-1729750087895 (c)
|    \--- org.slf4j:slf4j-api:2.0.13 (c)
+--- net.corda:corda-application -> 5.3.0.16-beta-1729750087895
|    +--- javax.persistence:javax.persistence-api:2.2
|    +--- net.corda:corda-api:5.3.0.16-beta-1729750087895 (*)
|    +--- net.corda:corda-base:5.3.0.16-beta-1729750087895
|    |    +--- net.corda:corda-api:5.3.0.16-beta-1729750087895 (*)
|    |    \--- org.slf4j:slf4j-api:2.0.13
|    +--- net.corda:corda-crypto:5.3.0.16-beta-1729750087895
|    |    +--- org.slf4j:slf4j-api:2.0.13
|    |    +--- net.corda:corda-api:5.3.0.16-beta-1729750087895 (*)
|    |    \--- net.corda:corda-base:5.3.0.16-beta-1729750087895 (*)
|    +--- net.corda:corda-membership:5.3.0.16-beta-1729750087895
|    |    +--- net.corda:corda-api:5.3.0.16-beta-1729750087895 (*)
|    |    \--- net.corda:corda-base:5.3.0.16-beta-1729750087895 (*)
|    \--- net.corda:corda-serialization:5.3.0.16-beta-1729750087895
|         +--- net.corda:corda-api:5.3.0.16-beta-1729750087895 (*)
|         \--- net.corda:corda-base:5.3.0.16-beta-1729750087895 (*)
\--- org.jetbrains.kotlin:kotlin-osgi-bundle:1.8.21

Only serialization-amqp depends on proton-j.

blsemo
blsemo previously approved these changes Oct 24, 2024
Copy link

@williamvigorr3 williamvigorr3 merged commit c80cfb8 into feature/ledger-library Oct 24, 2024
5 checks passed
@williamvigorr3 williamvigorr3 deleted the WillV/R3SOL-368-Extract-Ledger-Lib branch October 24, 2024 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants