Skip to content

Commit

Permalink
Merge pull request #4 from THCLab/thcf/rebase
Browse files Browse the repository at this point in the history
Thcf/rebase
  • Loading branch information
Krzosa Karol authored Oct 7, 2020
2 parents ee31aa9 + ac8b861 commit 32fc3eb
Show file tree
Hide file tree
Showing 59 changed files with 10,340 additions and 17 deletions.
225 changes: 224 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,226 @@
### Setup modified Acapy

1. Setup the initial enviroment first using the instructions from here https://github.com/THCLab/aries
2. Clone this repositiory into the aries folder from the first step
3. Add a volume to both agent instances pointing to the replacement aries_cloudagent like so:

```
volumes:
- ./aries-cloudagent-python/aries_cloudagent/:/home/indy/aries_cloudagent
```


Full version:
```
agent1.localhost:
image: humancolossus/agent:version-0.5.4-ext-1
command: /bin/bash -c "./startup.sh"
volumes:
- ./aries-cloudagent-python/aries_cloudagent/:/home/indy/aries_cloudagent
ports:
- '8150:8150'
environment:
AGENT_NAME: "Bob Smith"
ACAPY_ENDPOINT: http://agent1.localhost
SWAGGER_INBOUND_PORT: 8150
GENESIS_URL: http://webserver:8000/genesis
WEBHOOK_URL: ws://websocket_server1:5000
networks:
- von_von
agent2.localhost:
image: humancolossus/agent:version-0.5.4-ext-1
command: /bin/bash -c "./startup.sh"
volumes:
- ./aries-cloudagent-python/aries_cloudagent/:/home/indy/aries_cloudagent
ports:
- '8151:8150'
environment:
AGENT_NAME: "Alice Jones"
ACAPY_ENDPOINT: http://agent2.localhost
SWAGGER_INBOUND_PORT: 8150
GENESIS_URL: http://webserver:8000/genesis
WEBHOOK_URL: ws://websocket_server2:5000
networks:
- von_von
```

### Setup service plugin volume

1. Clone this repo https://github.com/THCLab/aries-services-plugin into the aries folder from step 1
<!-- 2. You need to swap the startup.sh script inside the agents docker containers using the volumes which is located in /home/indy/ let's first prepera -->
2. You need to insert the services plugin into the docker container /home/indy/ using the docker volumes like so:

```
volumes:
- ./aries-services-plugin/services/:/home/indy/services
```

Full version:
```
agent1.localhost:
image: humancolossus/agent:version-0.5.4-ext-1
command: /bin/bash -c "./startup.sh"
volumes:
- ./aries-services-plugin/services/:/home/indy/services
ports:
- '8150:8150'
environment:
AGENT_NAME: "Bob Smith"
ACAPY_ENDPOINT: http://agent1.localhost
SWAGGER_INBOUND_PORT: 8150
GENESIS_URL: http://webserver:8000/genesis
WEBHOOK_URL: ws://websocket_server1:5000
networks:
- von_von
agent2.localhost:
image: humancolossus/agent:version-0.5.4-ext-1
command: /bin/bash -c "./startup.sh"
volumes:
- ./aries-services-plugin/services/:/home/indy/services
ports:
- '8151:8150'
environment:
AGENT_NAME: "Alice Jones"
ACAPY_ENDPOINT: http://agent2.localhost
SWAGGER_INBOUND_PORT: 8150
GENESIS_URL: http://webserver:8000/genesis
WEBHOOK_URL: ws://websocket_server2:5000
networks:
- von_von
```
3. New endpoints should appear inside the acapy swagger admin API under http://localhost:8150


### Setup Vanilla Acapy compatible with external tests using jupyter notebook controller

1. Clone this repo (service plugin) https://github.com/THCLab/aries-services-plugin/tree/for-testing-vanilla-acapy into the aries folder from step 1
2. Clone (acapy 0.5.4) https://github.com/hyperledger/aries-cloudagent-python/tree/0.5.4 into the aries folder from step 1. Version 0.5.4. There is no guarantee that later or older versions wont break.
3. Mount both the cloned agent and the plugin into docker volumes, this will swap the files inside the container with the versions you cloned, like so:

```
volumes:
- ./aries-services-plugin/services/:/home/indy/services
- ./aries-cloudagent-python/aries_cloudagent/:/home/indy/aries_cloudagent
```

Full version:
```
agent1.localhost:
image: humancolossus/agent:version-0.5.4-ext-1
command: /bin/bash -c "./startup.sh"
volumes:
- ./aries-services-plugin/services/:/home/indy/services
- ./aries-cloudagent-python/aries_cloudagent/:/home/indy/aries_cloudagent
ports:
- '8150:8150'
environment:
AGENT_NAME: "Bob Smith"
ACAPY_ENDPOINT: http://agent1.localhost
SWAGGER_INBOUND_PORT: 8150
GENESIS_URL: http://webserver:8000/genesis
WEBHOOK_URL: ws://websocket_server1:5000
networks:
- von_von
agent2.localhost:
image: humancolossus/agent:version-0.5.4-ext-1
command: /bin/bash -c "./startup.sh"
volumes:
- ./aries-services-plugin/services/:/home/indy/services
- ./aries-cloudagent-python/aries_cloudagent/:/home/indy/aries_cloudagent
ports:
- '8151:8150'
environment:
AGENT_NAME: "Alice Jones"
ACAPY_ENDPOINT: http://agent2.localhost
SWAGGER_INBOUND_PORT: 8150
GENESIS_URL: http://webserver:8000/genesis
WEBHOOK_URL: ws://websocket_server2:5000
networks:
- von_von
```
4. New endpoints should appear inside the acapy swagger admin API under http://localhost:8150
5. Tests are located in the aries-services-plugin/controllers



### Setup Debugger

To enable the debugger you need to pass in the --debug flag to the Acapy start command, this will make the agent wait for a debugger attach, preventing any startup actions.

To have good compatibility between the source code inside the container and what you have locally its probably a good idea to add a volume to the docker compose this way the code inside the container is always exactly what you have locally

```
volumes:
- ./aries-cloudagent-python/aries_cloudagent/:/home/indy/aries_cloudagent
```

The debugger server by default starts on a 5678 port which needs to be published outside of the container like so in docker-compose:
```
ports:
- 8152:5678
```

```
where:
- portToPublishTo:portInsideContainer
```

If the agent is waiting with the port published than we can attach to it using the ptvsd debugger and VSCode, you might need download the ptvsd using pip like so:

> pip3 install ptvsd
Finally to begin debugging openup the acapy source code that is also mounted using a volume inside a docker container and click Ctrl + Shift + P (The command menu) type in "open launch.json" and paste in this code into the launch.json file:

```
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"port": 8152,
"host": "localhost",
"pathMappings": [
{
"localRoot": "${workspaceFolder}/aries_cloudagent",
"remoteRoot": "/home/indy/aries_cloudagent"
}
]
}
]
}
```
Make sure that pathMappings match exactly to what you have on your setup
Make sure that you use the correct port

To start debugging hit Ctrl + Shift + P (The command menu) type in start debugging.

### Present Proof

* Proof presentation step might not work properly if all the schema fields are not filled so that it doesnt have the None value(can be filled even with meaningless info)
* Errors seem to be propagated to the next stage of the protocol, even though first stage passed the next stage can throw a invalid structure error

### Code Keywords to look for what changed (case insensitive)

* Original
* Krzosa
* THCF












# Hyperledger Aries Cloud Agent - Python <!-- omit in toc -->

[![pypi releases](https://img.shields.io/pypi/v/aries_cloudagent)](https://pypi.org/project/aries-cloudagent/)
Expand Down Expand Up @@ -99,4 +322,4 @@ We also welcome issues submitted about problems you encounter in using ACA-Py.

## License

[Apache License Version 2.0](https://github.com/hyperledger/aries-cloudagent-python/blob/master/LICENSE)
[Apache License Version 2.0](https://github.com/hyperledger/aries-cloudagent-python/blob/master/LICENSE)
59 changes: 59 additions & 0 deletions README_THCF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
### Present Proof

* Proof presentation step might not work properly if all the schema fields are not filled so that it doesnt have the None value(can be filled even with meaningless info)
* Errors seem to be propagated to the next stage of the protocol, even though first stage passed the next stage can throw a invalid structure error

### Code Keywords to look for what changed (case insensitive)

* Original
* Krzosa
* THCF

### Debugger

To enable the debugger you need to pass in the --debug flag to the Acapy start command, this will make the agent wait for a debugger attach, preventing any startup actions.

To have good compatibility between the source code inside the container and what you have locally its probably a good idea to add a volume to the docker compose this way the code inside the container is always exactly what you have locally

volumes:
- ./aries-cloudagent-python/aries_cloudagent/:/home/indy/aries_cloudagent


The debugger server by default starts on a 5678 port which needs to be published outside of the container like so in docker-compose:
ports:
- 8152:5678

where:
- portToPublishTo:portInsideContainer

If the agent is waiting with the port published than we can attach to it using the ptvsd debugger and VSCode, you might need download the ptvsd using pip like so:

> pip3 install ptvsd
Finally to begin debugging openup the acapy source code that is also mounted using a volume inside a docker container and click Ctrl + Shift + P (The command menu) type in "open launch.json" and paste in this code into the launch.json file:

"""
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"port": 8152,
"host": "localhost",
"pathMappings": [
{
"localRoot": "${workspaceFolder}/aries_cloudagent",
"remoteRoot": "/home/indy/aries_cloudagent"
}
]
}
]
}
"""
Make sure that pathMappings match exactly to what you have on your setup
Make sure that you use the correct port

To start debugging hit Ctrl + Shift + P (The command menu) type in start debugging.

12 changes: 9 additions & 3 deletions aries_cloudagent/commands/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@ def execute(argv: Sequence[str] = None):
settings = get_settings(args)
common_config(settings)

# thcf
settings["public_storage_type"] = "local"
settings["public_storage_registered_types"] = {
"local": "aries_cloudagent.public_data_storage_thcf.local.LocalDataStorage",
"data_vault": "aries_cloudagent.public_data_storage_thcf.data_vault.DataVault",
"own_your_data": "aries_cloudagent.public_data_storage_thcf.own_your_data.OwnYourDataVault",
}
print(settings)

# set ledger to read only if explicitely specified
settings["ledger.read_only"] = settings.get("read_only_ledger", False)

# (Krzosa)
print("Start.py Settings", settings)

# Support WEBHOOK_URL environment variable
webhook_url = os.environ.get("WEBHOOK_URL")
if webhook_url:
Expand Down
13 changes: 13 additions & 0 deletions aries_cloudagent/config/default_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
from ..wallet.provider import WalletProvider


from ..public_data_storage_thcf.base import PublicDataStorage
from ..public_data_storage_thcf.provider import PublicDataStorageProvider


class DefaultContextBuilder(ContextBuilder):
"""Default context builder."""

Expand Down Expand Up @@ -77,6 +81,12 @@ async def bind_providers(self, context: InjectionContext):
),
)

# THCF
context.injector.bind_provider(
PublicDataStorage,
PublicDataStorageProvider(),
)

context.injector.bind_provider(
BaseLedger,
CachedProvider(
Expand Down Expand Up @@ -165,6 +175,9 @@ async def load_plugins(self, context: InjectionContext):
plugin_registry.register_plugin("aries_cloudagent.revocation")
plugin_registry.register_plugin("aries_cloudagent.wallet")

# thcf
plugin_registry.register_plugin("aries_cloudagent.public_data_storage_thcf")

# Register external plugins
for plugin_path in self.settings.get("external_plugins", []):
plugin_registry.register_plugin(plugin_path)
Expand Down
4 changes: 4 additions & 0 deletions aries_cloudagent/config/injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ async def inject(
"No instance provided for class: {}".format(base_cls.__name__)
)
elif not isinstance(result, base_cls) and self.enforce_typing:
print("result: ", result)
print("base_cls: ", base_cls)
print("self.enforce_typing: ", self.enforce_typing)
print("isinstance: ", isinstance(result, base_cls))
raise InjectorError(
"Provided instance does not implement the base class: {}".format(
base_cls.__name__
Expand Down
Loading

0 comments on commit 32fc3eb

Please sign in to comment.