Skip to content

Commit

Permalink
Work
Browse files Browse the repository at this point in the history
  • Loading branch information
bisgardo committed Apr 18, 2024
1 parent c2fb7bf commit 7fe288d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 27 deletions.
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -564,17 +564,25 @@ Also, the block containing the transaction has to be finalized for the transacti

## Testing

### Running Rosetta CLI for testing
### Rosetta CLI tool

We forked the Rosetta CLI tool to make it understand account aliases, i.e. that a
transaction affecting the balance of an account affects all aliases of that
account as well.
The Rosetta team maintains a CLI that includes commands for verifying that the implementation produces valid results.
This includes consistency checks of the balance of all accounts,
i.e. that all changes in balances are accounted for in transactions.

The test will fail if run with the official Rosetta CLI tool.
The test will fail if run with the official Rosetta CLI tool because it doesn't understand how Concordium does account aliases.
We therefore forked the tool to make it accept that a transaction affecting the balance of an
account affects all aliases of that account as well.

To run our forked rosetta-cli tool you must have a running instance of both the
To run the test you need a running instance of both the
[concordium-node](https://github.com/Concordium/concordium-node) and
the concordium rosetta API implementation:
the Conocordium Rosetta.

The easiest way to run Rosetta and the tool is by using the [provided](./docker-compose.yaml) Docker Compose deployment
with the profile `check-data` enabled.
See the following sections for alternative methods.

#### Build and run (direct)

```bash
concordium-rosetta --network testnet
Expand Down Expand Up @@ -606,7 +614,7 @@ We need to make the following changes to this configuration:
when Rosetta was started (i.e. `testnet` in the command above).
- The blockchain field should be set to `"concordium"`
- Setting `"max_retries": 32768` makes sure the test doesn't stop
on a tempoary network outage.
on a temporary network outage.

Now the test tool can be run:

Expand All @@ -619,10 +627,10 @@ Note that this only tests the data returned by the Rosetta
API implementation is valid. It does not test interaction
on chain, such as transactions. We test that with a different
[tool](https://github.com/Concordium/concordium-rosetta#transfer-client).
There is more info on the [Rosetta-API
website](https://www.rosetta-api.org/docs/rosetta_cli.html#checkdata-1).
There is more info on the
[Rosetta-API website](https://www.rosetta-api.org/docs/rosetta_cli.html#checkdata-1).

### Rosetta CLI (Docker)
#### Build and run (Docker)

You can also build using the provided docker file in [`tools/rosetta-cli-docker`](./tools/rosetta-cli-docker)

Expand Down
27 changes: 13 additions & 14 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@
# - The value of `CONCORDIUM_ROSETTA_PORT` only determines the port exposed to the host.
# The internal port is hard-coded to 8080.
# The default value of the exposed port is still 8080.
# Don't change this when running with profile 'check:data' as the Rosetta CLI expects to use this port on the host.
# Don't change this when running with profile 'check-data' as the Rosetta CLI expects to use this port on the host.
#
# The image containing the application is set using `ROSETTA_IMAGE`.
# If this value isn't provided, it will default to an image that doesn't exist in the public repo,
# which will cause Compose to build the image from source.
# If this value isn't provided, it will default to an image that doesn't exist publicly ("concordium-rosetta:test).
# This will cause Compose to build the image from source.
# Note that the image is cached locally so will be used without rebuild in subsequent runs, even if the source code has changed.
# Delete the image or change `ROSETTA_IMAGE` to rebuild.
#
# Finally, `CONCORDIUM_ROSETTA_NETWORK` has no default value so must be set explicitly.
#
# Example:
#
# ROSETTA_IMAGE=concordium/rosetta:0.7.0-0 \
# ROSETTA_IMAGE=concordium/rosetta:1.0.0-0 \
# CONCORDIUM_ROSETTA_GRPC_HOST=node.mainnet.concordium.example.com \
# CONCORDIUM_ROSETTA_NETWORK=mainnet \
# docker-compose up -d
# docker compose up -d
#
# For testing the implementation, an extra service `rosetta-cli-check-data` may be included.
# This is a custom fork of the official Rosetta CLI that understands Concordium account aliases (see './tools/rosetta-cli-docker').
# Run the deployment with Compose profile `check:data` to enable this service.
# Run the deployment with Compose profile `check-data` to enable this service.
# The baked in configuration of the tool expects the following:
# - Rosetta is exposed on port 8080 on the host network.
# - The network is set to "rosetta".
#
# Example:
# ROSETTA_IMAGE=concordium/rosetta:0.7.0-0 \
# ROSETTA_IMAGE=concordium/rosetta:1.0.0-0 \
# CONCORDIUM_ROSETTA_GRPC_HOST=node.mainnet.concordium.example.com \
# CONCORDIUM_ROSETTA_NETWORK=rosetta \
# docker-compose --profile=check:data up -d
# docker compose --profile=check-data up -d

version: '3'
services:
Expand All @@ -46,20 +46,19 @@ services:
build:
context: .
args:
build_image: ${ROSETTA_BUILD_IMAGE-rust:1.62-slim-buster}
build_image: ${ROSETTA_BUILD_IMAGE-rust:1.66-slim-buster}
base_image: ${ROSETTA_BASE_IMAGE-debian:buster-slim}
image: ${ROSETTA_IMAGE-concordium/rosetta:test}
image: ${ROSETTA_IMAGE-concordium-rosetta:test}
environment:
- CONCORDIUM_ROSETTA_GRPC_HOST=${CONCORDIUM_ROSETTA_GRPC_HOST-172.17.0.1}
- CONCORDIUM_ROSETTA_GRPC_PORT
- CONCORDIUM_ROSETTA_GRPC_TOKEN
- CONCORDIUM_ROSETTA_NETWORK
- CONCORDIUM_ROSETTA_PORT=8080
ports: # alternative: use "network_mode: host"
ports:
- "${CONCORDIUM_ROSETTA_PORT-8080}:8080"
stop_signal: SIGKILL
rosetta-cli-check-data:
profiles: [check:data]
profiles: [ check-data ]
container_name: rosetta-cli-check-data
build:
context: ./tools/rosetta-cli-docker
Expand All @@ -72,4 +71,4 @@ services:
depends_on:
- rosetta
command:
- check:data
- "check:data"
4 changes: 2 additions & 2 deletions tools/transfer-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ It's not meant to be used to do real transfers as there are other tools that are

The tool is specifically built to integrate with the Concordium Rosetta implementation;
implementations for other blockchains are not supported.
The main Concordium-specific parts are key handling and the [signature index quirk](/README.md#construction_api)
The main Concordium-specific parts are key handling and the [signature index quirk](/README.md#construction-api)
in the `combine` endpoint.

## Usage
Expand All @@ -35,7 +35,7 @@ The expected JSON format of the keys file is
"keys": {
<key-index>: {
"signKey": ...,
"verifyKey": ...,
"verifyKey": ...
},
...
},
Expand Down

0 comments on commit 7fe288d

Please sign in to comment.