Skip to content

Commit

Permalink
Evaluation fixes (#27)
Browse files Browse the repository at this point in the history
* Update INSTRUCTIONS.md

* Update README.md

* Update README.md
  • Loading branch information
dastansam authored May 21, 2024
1 parent 31d6202 commit d88b4fd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 32 deletions.
11 changes: 6 additions & 5 deletions INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ Compile and run the node with:
cargo run --release -- --dev --tmp
```

Insert image ID with `fiatRamps::setRisc0ImageId` extrinsic call. This is necessary for offchain worker to know which image to use when running the `riscv0` module. Go to `Sudo` tab and choose `fiatRamps -> setRisc0ImageId` extrinsic and paste the image ID from the previous step, make sure to prepend the image ID with `0x`. Click `Submit transaction`. Sudo account is a development account `Dave`.

<img width="1722" alt="Set Image ID" src="https://github.com/element36-io/ocw-ebics/assets/88332432/c099cd03-4003-4c88-8b24-6099a3145f8f">


Open PolkadotJs [interface](https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944#/explorer) and go to `Developer -> RPC calls` page. Here, we first need to enter keypair for our offchain worker, since it will be signing and submitting transactions to the chain. Choose `author -> insertKey` RPC call and fill out the fields with the following values:

```js
Expand All @@ -67,10 +72,6 @@ suri: cup swing hill dinner pioneer mom stick steel sad raven oak practice
public_key: 5C555czPfaHgYhKhsRg2KNCLGCJ82jVsvweTHAnfvT83uy5T
```

Insert image ID with `fiatRamps::setRisc0ImageId` extrinsic call. This is necessary for offchain worker to know which image to use when running the `riscv0` module. Choose `fiatRamps -> setRisc0ImageId` extrinsic and paste the image ID from the previous step. Click `Submit transaction`.

![Image ID](/assets/image-id.png)

Then, choose `FiatRamps.setApiUrl` extrinsic and paste the new url for the API and click `Submit transaction`. This is only necessary if you have a different URL than the default one with Ebics Java service.

Once you have submitted the call, head over to `Extrinsics -> fiatRamps -> createAccount` call. Here we need to map Alice's IBAN number to his on-chain account address. Simply choose Alice as a signer, copy and paste value of the IBAN number from the following JSON file and submit the extrinsic.
Expand Down Expand Up @@ -149,4 +150,4 @@ After we submit extrinsic, we can see that the burn request event is created.
Shortly after (approximately 3-4 blocks), we can notice that the burn request has been processed and transfer between Alice and Jack occurs. Notice that transfer occurs from an unknown wallet to Jack, not directly from Alice to Jack. This is offchain worker's account that stores the funds until transaction is finalized by LibEUfin backend.

![Extrinsic from Alice to Jack](/assets/alice-jack-event-zk.png)


52 changes: 25 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,15 @@ Note: the above code might take long to compile depending on your machine specs

## Run

The OWC needs the backend which connects to the bank account, which is provided by
[this project](https://github.com/element36-io/ebics-java-service). We run the test version of the API in our own server and it is used as default API url for the offchain worker. However, sudo user can change the API url by submitting an extrinsic. If you want to run your local backend instance:

```sh
docker run -p 8093:8093 e36io/ebics-service
```
There are some known issues with running the backend on M1 Silicon chips, so use our server if that's the case.
This chain needs EBICS Java service, which is responsible for connecting to the bank account and providing an API for our offchain worker to interact with. You can find the service [here](https://github.com/element36-io/ebics-java-service). Follow the instructions in the README to run the service.

Now start the OCW. The provided `cargo run` command will launch a temporary node and its state will be discarded after
you terminate the process. After the project has been built, there are other ways to launch the
node.

```sh
./target/release/node-template --dev --tmp

# or, simply:
make launch-chain
```
cargo run --release --dev --tmp

You can run the development node with temporary storage:

```sh
./target/release/node-template --dev --tmp
# or, simply:
make launch-chain
```
Expand Down Expand Up @@ -169,28 +155,40 @@ public_key: 5C555czPfaHgYhKhsRg2KNCLGCJ82jVsvweTHAnfvT83uy5T

You can set the new url for the `ebics-service` via PolkadotJS interface. Follow this link to the `Sudo` [tab](https://polkadot.js.org/apps/#/sudo) and choose `FiatRamps.setApiUrl` extrinsic. Paste the new url for the API and click `Submit transaction`. If everything is good, i.e you are the Sudo account and you have the necessary rights, you should see the transaction included in the block and offchain worker starts querying the new API.

### Run in Docker
### Run with Docker


First, install [Docker](https://docs.docker.com/get-docker/) and
[Docker Compose](https://docs.docker.com/compose/install/).

Then run the following command to start a single node development chain.

Docker:
Run with image from DockerHub:

```bash
# Ready to use docker image
docker run -it -p 9944:9944 e36io/ebics-ocw:hyperfridge --dev --tmp --unsafe-rpc-external --rpc-cors=all --rpc-methods=unsafe -loffchain-worker
```

# Build docker image MacOS (M1)
docker build --platform linux/x86_64 -t ebics-ocw .
#### Docker (Linux)

# Build docker image Linux
Build:
```
docker build -t ebics-ocw .
```

# Run docker image MacOS (M1)
docker run --platform=linux/x86_64 -it -p 9944:9944 ebics-ocw:latest --dev --tmp --unsafe-rpc-external --rpc-cors=all --rpc-methods=unsafe -loffchain-worker

# Run docker image Linux
Run:
```
docker run -it -p 9944:9944 ebics-ocw:latest --dev --tmp --unsafe-rpc-external --rpc-cors=all --rpc-methods=unsafe -loffchain-worker
```
```

#### Docker (MacOS)

Build:
```
docker build --platform linux/x86_64 -t ebics-ocw .
```

Run:
```
docker run --platform=linux/x86_64 -it -p 9944:9944 ebics-ocw:latest --dev --tmp --unsafe-rpc-external --rpc-cors=all --rpc-methods=unsafe -loffchain-worker
```

0 comments on commit d88b4fd

Please sign in to comment.