Skip to content

Commit

Permalink
Always publish ZKFlow locally for sample
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbos committed Nov 9, 2022
1 parent f176a59 commit 8861b9c
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 136 deletions.
2 changes: 1 addition & 1 deletion .ci/azure-pipelines-scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ steps:
publishJUnitResults: true
testResultsFiles: '**/TEST-*.xml'
# codeCoverageToolOption: JaCoCo # Broken because it expects hardcoded 'build.gradle' instead of 'build.gradle.kts'
tasks: 'clean cleanTest check test testReport jacocoRootReport checkLicense'
tasks: 'clean cleanTest check test testReport jacocoRootReport checkLicense spotBugsMain'
options: '--no-build-cache --rerun-tasks --no-daemon --no-parallel'
env:
GITHUB_USERNAME: $(github.username)
Expand Down
2 changes: 1 addition & 1 deletion .ci/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ steps:
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/TEST-*.xml'
tasks: 'clean cleanTest check test testReport jacocoRootReport checkLicense'
tasks: 'clean cleanTest check test testReport jacocoRootReport checkLicense spotBugsMain'
# options: '--stacktrace --info --build-cache'
options: '--no-build-cache --rerun-tasks --no-daemon --no-parallel --stacktrace --info '
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
echo "$GITHUB_WORKSPACE/zinc-linux/" >> $GITHUB_PATH
- name: Build with Gradle
run: ./gradlew clean cleanTest check test testReport jacocoRootReport checkLicense spotBugsMain publishToMavenLocal --no-build-cache --rerun-tasks --no-daemon --no-parallel --stacktrace --info
run: ./gradlew clean cleanTest check test testReport jacocoRootReport checkLicense spotBugsMain --no-build-cache --rerun-tasks --no-daemon --no-parallel --stacktrace --info
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
49 changes: 0 additions & 49 deletions .github/workflows/on-tag-publish.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/scheduled-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
echo "$GITHUB_WORKSPACE/zinc-linux/" >> $GITHUB_PATH
- name: Build with Gradle
run: ./gradlew clean cleanTest check test testReport jacocoRootReport checkLicense spotBugsMain publishToMavenLocal --no-build-cache --rerun-tasks --no-daemon --no-parallel --stacktrace --info
run: ./gradlew clean cleanTest check test testReport jacocoRootReport checkLicense spotBugsMain --no-build-cache --rerun-tasks --no-daemon --no-parallel --stacktrace --info
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
52 changes: 22 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,47 @@ Features:

To learn more about ZKFlow internals, there is a [docs](docs) directory in this repo. In addition to the [ZKFLow white paper](docs/ZKFlow_whitepaper.pdf), it contains technical documentation in Markdown and PDF format. There is also plenty of documentation throughout the code itself, explaining logic or rationale. Finally, the many test cases will also explain a lot about expected behaviour.

## Testing ZKFlow with the sample CorDapp or with your own CorDapp
## Running the sample ZKDapp

The ZKFlow jars are currently not deployed to one of the Maven/Gradle repositories. This means it can not be used directly by CorDapps. Instead, run the tests for ZKFlow and the `sample-zkdapp` to see it in action.
The sample ZKDapp demonstrates how a basic token contract can be adapted to work with ZKFlow. The contract tests and flow tests show the expected behaviour.

Please make sure you have satisfied all [prerequisites](#prerequisites) before you execute the following:

```bash
$ cd sample-zkdapp
$ cd zkflow/sample-zkdapp
$ ./gradlew test
```

If you want to test ZKFlow with your own CorDapp, please do the following:
## Running your own CorDapp with ZKFlow

* Copy you CorDapp to the zkflow project, similar to `sample-zkdapp`
* Add `includeBuild("..")` to your `settings.gradle`. This will give your CorDapp access to undeployed ZKFlow artifacts
* Enable the ZKFlow Gradle plugin on your CorDapp in your `build.gradle.kts`. Note that it needs no version because of `includeBuild("..")`:
> [i] This assumes you use the Kotlin DSL for your Gradle build files. If you do not, change accordingly for the Groovy DSL. The changes should be identical except for syntax.
The ZKFlow jars are currently not deployed to one of the public Maven/Gradle repositories. If you want to test ZKFlow with your own CorDapp, please make the following changes to your build file:

* Make sure that ZKFlow is published to your local Maven repository by running `./gradlew publishToMavenLocal` in the ZKFlow directory.
* Add the `mavenLocal()` repository to your repositories for Gradle plugins (probably in the `pluginManagement` block in your `settings.gradle.kts`) and to your repositories for normal Gradle dependencies in your `build.gradle.kts`.
* Enable the ZKFlow Gradle plugin on your CorDapp in your `build.gradle.kts`.

```kotlin
plugins {
id("com.ing.zkflow.gradle-plugin")
id("com.ing.zkflow.gradle-plugin") version "1.0-SNAPSHOT"
}
```
* To be able to use ZKFlow's contract test DSL and other convenience functions, add `testImplementation("com.ing.zkflow:test-utils:1.0-SNAPSHOT")` to your `dependencies` block in `build.gradle.kts`.
* Finally, adapt your contracts, states, commands, contract tests and flow tests to work with ZKFlow. You can inspect `sample-zkdapp` to see how you can make those adaptations. Please note that some significant changes to your state class definitions may be required.
Not you are ready to adapt your contracts, states, commands, contract tests and flow tests to work with ZKFlow. You can inspect `sample-zkdapp` to see how you can make those adaptations. Please note that some significant changes to your state class definitions may be required.
Not recommended, but feel free to run it immediately as-is and let ZKFlow tell you what should be added to your classes.
## Troubleshooting the sample ZKDapp or your own ZKDapp
Build issues:
- `java.lang.IllegalArgumentException: Cannot find circuit manifest`: This should not happen during normal development flow, but it can be solved by running `./gradlew generateZincCircuits --rerun-tasks` in your ZKDapp.
## Running ZKFlow tests
If you want to make changes to ZKFlow itself, you need to be able to run its tests.
This is as simple as running `./gradlew test` in the ZKFlow root directlty. It will run all tests, including integration tests.
This is as simple as running `./gradlew test` in the ZKFlow root directly. It will run all tests, including integration tests.
Please make sure you have satisfied all [prerequisites](#prerequisites) before running the tests.
## Prerequisites for running ZKFlow
Expand All @@ -71,26 +83,6 @@ $ cargo b --release
Built binaries will be stored in `./target/release`. Move the `zargo`, `znc` and `zvm` binaries to a directory you prefer and add it to your systems PATH. `/usr/local/bin` has been known to work. Then you can delete sources.
#### Zinc on internal Azure Pipelines
If you make changes to Zinc and create a new tag, please ensure that the [copy of the binaries](./.ci/lib/zinc-linux.tar.gz) in for Azure Pipelines is updated to be that version. Please note that these binaries should be compiled on/for linux, so they can run on the Azure Pipelines agents.
For GitHub Actions, this is not required, as that build automatically downloads and installs the correct Zinc binaries.
### Gradle
Typically, Gradle does not require any specific changes, but you might encounter the following error during the build (path can be different):
```bash
Caused by: java.io.IOException: Cannot run program "zargo" (in directory "/Users/mq23re/Developer/zk-notary/prover/circuits/create"): error=2, No such file or directory
```
To fix it, run the command below from the project directory. It will stop daemon, thus it will clear cache, which can help to resolve the issue.
```bash
./gradlew --stop
```
## Contributing to ZKFlow
If you want to make changes to ZKFlow, great! We welcome pull requests at any time. If you decide to create a PR, please keep the [contributing guidelines](CONTRIBUTING.md) in mind.
2 changes: 1 addition & 1 deletion bin/pre-push-checks
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fi

fail_all_if_failed \
"Build with Gradle" \
"./gradlew $clean check test testReport jacocoRootReport checkLicense spotBugsMain publishToMavenLocal --stacktrace"
"./gradlew $clean check test testReport jacocoRootReport checkLicense spotBugsMain --stacktrace --info"

fail_all_if_failed \
"sample-zkdapp - Build with Gradle" \
Expand Down
2 changes: 2 additions & 0 deletions sample-zkdapp/bin/run_issuer_for_rpc.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This script assumes that ./gradlew deployNodes was run first.

cd build/nodes/Issuer || exit

nohup java -Dexperimental.corda.customSerializationScheme=com.ing.zkflow.common.serialization.BFLSerializationScheme \
Expand Down
2 changes: 2 additions & 0 deletions sample-zkdapp/bin/run_notary_for_rpc.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This script assumes that ./gradlew deployNodes was run first.

cd build/nodes/ZKNotary || exit

nohup java -Dexperimental.corda.customSerializationScheme=com.ing.zkflow.common.serialization.BFLSerializationScheme \
Expand Down
22 changes: 21 additions & 1 deletion sample-zkdapp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
buildscript {
// Please note that this is only required because the ZKFlow artifacts are currently not published to a public maven repository.
// For that reason, we always ensure that the latest version of ZKFlow is published locally before running the CorDapp build.
println("ENSURING LATEST ZKFLOW IS PUBLISHED TO LOCAL MAVEN REPOSITORY...")
exec {
workingDir = projectDir.parentFile
executable = "./gradlew"
args("publishToMavenLocal")
}

extra.apply{
set("corda_release_version", "4.8.5")
}
Expand Down Expand Up @@ -113,4 +122,15 @@ tasks.register<net.corda.plugins.Cordform>("deployNodes") {
}
rpcUsers = listOf(mapOf( Pair("user", "user1"), Pair("password", "test"), Pair("permissions", listOf("ALL"))))
}
}
}

// tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>() {
// doFirst {
// println("ENSURING LATEST ZKFLOW IS PUBLISHED TO LOCAL MAVEN REPOSITORY...")
// exec {
// workingDir = projectDir.parentFile
// executable = "./gradlew"
// args("publishToMavenLocal")
// }
// }
// }
42 changes: 0 additions & 42 deletions sample-zkdapp/config/test/log4j2.xml

This file was deleted.

9 changes: 0 additions & 9 deletions sample-zkdapp/config/test/logging-test.properties

This file was deleted.

0 comments on commit 8861b9c

Please sign in to comment.