-
Notifications
You must be signed in to change notification settings - Fork 76
docs: Describe running defra against sourcehub #5158
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
base: develop
Are you sure you want to change the base?
Changes from 3 commits
27b0897
262942a
881ad8f
f33b7cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -491,6 +491,73 @@ Because the certificates are self-signed, HTTPS clients must be configured to tr | |
| ## Access Control System | ||
| Learn more about the [Document Access Control](https://docs.source.network/defradb/security/document-access-control/) system. | ||
|
|
||
| ### Using SourceHub for Document ACP | ||
|
|
||
| By default, Document ACP is local to the node. Setting `acp.document.type` to `source-hub` stores policies and relationships on a [SourceHub](https://github.com/sourcenetwork/sourcehub) chain instead, which is what makes them verifiable across nodes. | ||
|
|
||
| Four parameters are required on the node when that type is selected, and one more on the client: | ||
|
|
||
| | Parameter | Side | Description | | ||
| | --- | --- | --- | | ||
| | `acp.document.sourceHub.ChainID` | node | ID of the chain to write ACP data to | | ||
| | `acp.document.sourceHub.GRPCAddress` | node | address of the SourceHub gRPC server | | ||
| | `acp.document.sourceHub.CometRPCAddress` | node | address of the SourceHub Comet RPC server | | ||
| | `acp.document.sourceHub.KeyName` | node | keyring entry holding the secp256k1 key that signs and pays for SourceHub transactions | | ||
| | `acp.document.sourceHub.address` | client | SourceHub address allowed to act on the client's behalf | | ||
|
|
||
| The signing key is a regular keyring entry, so it is added the same way as any other key: | ||
|
|
||
| ```shell | ||
| defradb keyring add sourcehub-key <secp256k1-private-key-hex> | ||
| ``` | ||
|
|
||
| #### Running a SourceHub node locally | ||
|
|
||
| For local development, the SourceHub image can run an isolated chain of its own with `STANDALONE=1`, which is also how the integration tests bring it up: | ||
|
|
||
| ```shell | ||
| docker run --rm \ | ||
| -e STANDALONE=1 \ | ||
| -p 26657:26657 -p 9090:9090 \ | ||
| ghcr.io/sourcenetwork/sourcehub:dev | ||
| ``` | ||
|
|
||
| It exposes gRPC on `9090` and Comet RPC on `26657`, and the chain is `sourcehub-dev`. The standalone image also creates a funded `faucet` account, whose mnemonic is printed in the container logs. | ||
|
|
||
| The account behind `KeyName` pays for the SourceHub transactions the node creates, and the faucet does not fund it automatically. Either import the faucet mnemonic as the node's key, or send funds to the address derived from the key already in the keyring: | ||
|
Comment on lines
+527
to
+529
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
commit=1bce44032618
entrypoint="$(curl -fsSL "https://raw.githubusercontent.com/sourcenetwork/sourcehub/${commit}/docker/entrypoint.sh")"
faucet_key="$(curl -fsSL "https://raw.githubusercontent.com/sourcenetwork/sourcehub/${commit}/docker/faucet-key.json")"
printf '%s\n' "$entrypoint" | grep -qF 'echo $DEV_FACUET_MNEMONIC | sourcehubd keys add faucet'
printf '%s\n' "$faucet_key" | grep -q '"mnemonic"'
echo "Verified the pinned faucet recovery flow without printing the mnemonic."Repository: sourcenetwork/defradb Length of output: 231 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- README context ---'
sed -n '515,540p' README.md
printf '%s\n' '--- pinned entrypoint ---'
curl -fsSL 'https://raw.githubusercontent.com/sourcenetwork/sourcehub/1bce44032618/docker/entrypoint.sh'Repository: sourcenetwork/defradb Length of output: 4651 Remove the claim that the faucet mnemonic is printed. Standalone startup recovers the hard-coded mnemonic without printing it. Document the supported faucet-key source, or remove the import branch and keep the funded- 🤖 Prompt for AI AgentsSource: MCP tools |
||
|
|
||
| ```shell | ||
| docker exec <container> sourcehubd tx bank send \ | ||
| faucet <address of the KeyName key> 1000000uopen \ | ||
| --keyring-backend test --chain-id sourcehub-dev --yes | ||
| ``` | ||
|
Comment on lines
+532
to
+535
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Give the new The preceding Proposed fix docker run --rm \
+ -d --name sourcehub \
-e STANDALONE=1 \
-p 26657:26657 -p 9090:9090 \
ghcr.io/sourcenetwork/sourcehub:dev
-docker exec <container> sourcehubd tx bank send \
+docker exec sourcehub sourcehubd tx bank send \🤖 Prompt for AI AgentsSource: MCP tools |
||
|
|
||
| A node is pointed at it through the config file at `~/.defradb/config.yaml`: | ||
|
|
||
| ```yaml | ||
| acp: | ||
| document: | ||
| type: source-hub | ||
| sourceHub: | ||
| ChainID: sourcehub-dev | ||
| GRPCAddress: 127.0.0.1:9090 | ||
| CometRPCAddress: 127.0.0.1:26657 | ||
| KeyName: sourcehub-key | ||
| ``` | ||
|
|
||
| Only `acp.document.type` and `acp.document.sourceHub.address` have CLI flags (`--document-acp-type` and `--source-hub-address`); the rest are set in the config file or through the environment, where `DEFRA_` is prefixed and dots become underscores: | ||
|
|
||
| ```shell | ||
| export DEFRA_ACP_DOCUMENT_TYPE=source-hub | ||
| export DEFRA_ACP_DOCUMENT_SOURCEHUB_CHAINID=sourcehub-dev | ||
| export DEFRA_ACP_DOCUMENT_SOURCEHUB_GRPCADDRESS=127.0.0.1:9090 | ||
| export DEFRA_ACP_DOCUMENT_SOURCEHUB_COMETRPCADDRESS=127.0.0.1:26657 | ||
| export DEFRA_ACP_DOCUMENT_SOURCEHUB_KEYNAME=sourcehub-key | ||
| defradb start | ||
| ``` | ||
|
|
||
| The SourceHub version DefraDB is built against is pinned in `go.mod`, currently `github.com/sourcenetwork/sourcehub v0.4.1-0.20260128164915-1bce44032618`; use a node built from that revision when running against something other than the `dev` image. | ||
|
|
||
| ## Supporting CORS | ||
|
|
||
| When accessing DefraDB through a frontend interface, you may be confronted with a CORS error. That is because, by default, DefraDB will not have any allowed origins set. To specify which origins should be allowed to access your DefraDB endpoint, you can specify them when starting the database: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.