A combination pinning service, resolver and indexer for the data module on Regen Ledger.
Try the Redwood pinning service here: https://redwood-data.cambium.cc/docs
Note: This project is under active development!
This application provides services to add supporting data for credit classes, projects, and credit batches that are created and managed using the ecocredit module on Regen Ledger.
For more information see the Data module and Concepts documentation.
The pinning service facilitates the processing and anchoring RDF graph data on-chain:
- A JSON-LD document is sent to the pinning service where it is canonicalized and procssed into a Content Hash.
- The content hash is anchored on-chain to provide "secure timestamping".
- An IRI is generated to uniquely identify the data.
- The anchored data is registered with the resolver. The original canonicalized data is stored in the pinning service database for later retrieval.
A resolver is used to retrieve data that has been stored off chain and anchored on chain. The pinning service can be used to retrieve the data it has anchored on-chain. Graph data that is provided by the resolver can be requested in multiple serialization formats.
Graph data that is anchored on-chain can optionally be indexed into an Apache Jena graph database for more efficient retrieval and querying of data.
Copy the .env.default
file to .env
and populate as necessary for a given
chain and node.
Follow these steps to configure a mangager
and service
account before
starting all of the docker containers:
Note: docker images need to be built locally at this time
- Create a
manager
account that will be used to define a resolver and delegate access to an ephemeral service accounts used in deployments of the pinning service.
regen keys add manager
- Define a resolver with the
manager
account.
MANAGER=regen1fy4jz0sx0prrx9n9jw4aeehmh0u52q657408kr
regen tx data define-resolver "http://service:8000/resource" --from $MANAGER --node http://redwood.regen.network:26657/ --chain-id regen-redwood-1 -b block -y
- Configure the
worker
container with aservice
account. This account will not hold any tokens and is designed to be thrown away and regenerated with new deployments as needed.
docker compose run worker regen config keyring-backend test
$ docker compose run worker regen keys add service --no-backup
- Grant the
service
account access to register data to the resolver on behalf of themanager
account.
SERVICE=regen1tz2pd06tcdyfxr7yn4ynv2hnutypxzed752meh
# Authz grant for MsgRegisterResolver.
regen tx authz grant $SERVICE generic --msg-type /regen.data.v1.MsgRegisterResolver --from $MANAGER --node http://redwood.regen.network:26657/ --chain-id regen-redwood-1 -b block -y
# Feegrant allows service account to not need tokens.
regen tx feegrant grant $MANAGER $SERVICE --allowed-messages /cosmos.authz.v1beta1.MsgExec,/regen.data.v1.MsgRegisterResolver --node http://redwood.regen.network:26657/ --chain-id regen-redwood-1 -b block -y
- Copy relevant information to the
.env
file:
- Copy the
manager
address to theREGEN_KEY_ADDRESS
in.env
- Set the
REGEN_RESOLVER_ID
to the ID returned above. - Copy the
service
address to theREGEN_SERVICE_KEY_ADDRESS
in.env
- Recreate the docker containers. It is important to recreate with new env variables.
docker compose down && docker compose up -d
# Verify the worker still has the same service account.
docker compose run worker regen keys show -a service
-
Use the health endpoint to ensure that the node, accounts and grants are properly configured on-chain
GET /health
:http://localhost:8000/docs#/default/health_health_get
-
Try anchoring new JSON-LD documents via the API
POST /resource
:http://localhost:8000/docs#/default/post_resource_resource_post
-
Check the anchor status:
GET /resource/{iri}
:http://localhost:8000/docs#/default/get_resource_status_resource__iri__status_get
-
Verify the anchor was indexed to the Jena database (click on "Edit" and "List graphs" to see all data:
http://localhost:3030/dataset.html
- First build the base image.
docker build . -f docker/base.Dockerfile -t pinning-service-base
- Build remaining images.
docker compose build
The Makefile
includes commands to start and configure a localnet for testing locally:
make localnet-start
: Start an existing or init a new localnet.
make localnet-configure
: Configure the localnet with keys and manager -> service account grants.
make localnet-stop
: Stop the localnet.
make localnet-clean
: Destroy the localnet, keys and data.
make -C localnet register-resolver
: Register data to the resolver using the service account. Can be used for testing.