Make chain-id, transferAmount and dailyLimit configurable
This commit is contained in:
parent
133637e044
commit
e19f83c726
@ -2,16 +2,24 @@ services:
|
|||||||
start-faucet:
|
start-faucet:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
image: cerc/laconic-faucet:local
|
image: cerc/laconic-faucet:local
|
||||||
|
command: ["bash", "-c", "./start-faucet.sh"]
|
||||||
environment:
|
environment:
|
||||||
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
||||||
|
CERC_LACONICD_RPC_ENDPOINT: ${CERC_LACONICD_RPC_ENDPOINT:-http://laconicd:26657}
|
||||||
CERC_FAUCET_KEY: ${CERC_FAUCET_KEY}
|
CERC_FAUCET_KEY: ${CERC_FAUCET_KEY}
|
||||||
CERC_RPC_ENDPOINT: ${CERC_RPC_ENDPOINT}
|
CERC_LACONICD_CHAIN_ID: ${CERC_LACONICD_CHAIN_ID:-laconic_9000-1}
|
||||||
entrypoint: "bash"
|
CERC_TRANSFER_AMOUNT: ${CERC_TRANSFER_AMOUNT:-1000000}
|
||||||
command: "./start-faucet.sh"
|
CERC_DAILY_LIMIT: ${CERC_DAILY_LIMIT:-3000000}
|
||||||
volumes:
|
volumes:
|
||||||
- ../config/laconic-faucet/start-faucet.sh:/app/start-faucet.sh
|
- ../config/laconic-faucet/start-faucet.sh:/app/start-faucet.sh
|
||||||
- ../config/laconic-faucet/config-template.toml:/app/environments/config-template.toml
|
- ../config/laconic-faucet/config-template.toml:/app/environments/config-template.toml
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- 3000
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
- "host.docker.internal:host-gateway"
|
- "host.docker.internal:host-gateway"
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "nc", "-vz", "127.0.0.1", "3000"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
start_period: 5s
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
[upstream]
|
[upstream]
|
||||||
rpcEndpoint = "REPLACE_WITH_RPC_ENDPOINT"
|
rpcEndpoint = "REPLACE_WITH_CERC_LACONICD_RPC_ENDPOINT"
|
||||||
chainId = "laconic_9000-1"
|
chainId = "laconic_9000-1"
|
||||||
denom = "photon"
|
denom = "photon"
|
||||||
prefix = "laconic"
|
prefix = "laconic"
|
||||||
faucetKey = "REPLACE_WITH_CERC_FAUCET_KEY"
|
faucetKey = "REPLACE_WITH_CERC_FAUCET_KEY"
|
||||||
|
|
||||||
[server]
|
[server]
|
||||||
transferAmount = 1000000
|
port=3000
|
||||||
dailyLimit = 3000000
|
transferAmount = "REPLACE_WITH_CERC_TRANSFER_AMOUNT"
|
||||||
|
dailyLimit = "REPLACE_WITH_CERC_DAILY_LIMIT"
|
||||||
dbDir = "db"
|
dbDir = "db"
|
||||||
|
29
stack-orchestrator/config/laconic-faucet/start-faucet.sh
Normal file → Executable file
29
stack-orchestrator/config/laconic-faucet/start-faucet.sh
Normal file → Executable file
@ -7,7 +7,7 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
config_template=$(cat environments/config-template.toml)
|
config_template=$(cat environments/config-template.toml)
|
||||||
local_config="./environments/local.toml"
|
target_config="./environments/local.toml"
|
||||||
|
|
||||||
# Check if faucet key is set
|
# Check if faucet key is set
|
||||||
if [ -z "${CERC_FAUCET_KEY:-}" ]; then
|
if [ -z "${CERC_FAUCET_KEY:-}" ]; then
|
||||||
@ -16,25 +16,20 @@ if [ -z "${CERC_FAUCET_KEY:-}" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
faucet_key=${CERC_FAUCET_KEY}
|
faucet_key=${CERC_FAUCET_KEY}
|
||||||
|
rpc_endpoint=${CERC_LACONICD_RPC_ENDPOINT}
|
||||||
|
transfer_amount=${CERC_TRANSFER_AMOUNT}
|
||||||
|
daily_limit=${CERC_DAILY_LIMIT}
|
||||||
|
|
||||||
# Check if RPC endpoint is set
|
echo "Using laconicd RPC endpoint: $rpc_endpoint"
|
||||||
if [-z "${CERC_RPC_ENDPOINT:-}" ]; then
|
echo "Transfer amount per request: $transfer_amount"
|
||||||
echo "Error: CERC_RPC_ENDPOINT is not set. Exiting..."
|
echo "Daily transfer amount limit for an address: $daily_limit"
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
rpc_endpoint=${CERC_RPC_ENDPOINT}
|
|
||||||
echo "The RPC endpoint is $rpc_endpoint"
|
|
||||||
|
|
||||||
FAUCET_CONFIG=$(echo "$config_template" | \
|
FAUCET_CONFIG=$(echo "$config_template" | \
|
||||||
sed -E "s|REPLACE_WITH_CERC_FAUCET_KEY|${faucet_key}|; s|REPLACE_WITH_RPC_ENDPOINT|${rpc_endpoint}|")
|
sed -E "s|REPLACE_WITH_CERC_FAUCET_KEY|${faucet_key}|g; \
|
||||||
|
s|REPLACE_WITH_CERC_LACONICD_RPC_ENDPOINT|${rpc_endpoint}|g; \
|
||||||
|
s|REPLACE_WITH_CERC_TRANSFER_AMOUNT|${transfer_amount}|g; \
|
||||||
|
s|REPLACE_WITH_CERC_DAILY_LIMIT|${daily_limit}|; ")
|
||||||
|
|
||||||
echo "$FAUCET_CONFIG" > $local_config
|
echo "$FAUCET_CONFIG" > $target_config
|
||||||
|
|
||||||
echo "Updated config file"
|
|
||||||
echo "Config.toml:"
|
|
||||||
cat $local_config
|
|
||||||
|
|
||||||
# Start node-js server
|
|
||||||
echo "Starting faucet..."
|
echo "Starting faucet..."
|
||||||
yarn start-faucet
|
yarn start-faucet
|
||||||
|
@ -1,16 +1,6 @@
|
|||||||
# laconic-faucet
|
# laconic-faucet
|
||||||
|
|
||||||
Instructions for running the laconic faucet server
|
Instructions for running the laconic faucet
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
* Minimum hardware requirements:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
RAM: 8-16GB
|
|
||||||
Disk space: 200GB
|
|
||||||
CPU: 2 cores
|
|
||||||
```
|
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
@ -62,12 +52,25 @@ Instructions for running the laconic faucet server
|
|||||||
* Inside the `laconic-faucet-deployment` deployment directory, open `config.env` file and set following env variables:
|
* Inside the `laconic-faucet-deployment` deployment directory, open `config.env` file and set following env variables:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Private key of faucet
|
||||||
CERC_FAUCET_KEY=
|
CERC_FAUCET_KEY=
|
||||||
CERC_RPC_ENDPOINT=
|
|
||||||
|
# Optional
|
||||||
|
|
||||||
|
# laconicd RPC endpoint (default: http://laconicd:26657)
|
||||||
|
CERC_LACONICD_RPC_ENDPOINT=
|
||||||
|
|
||||||
|
# laconicd chain id (default: laconic_9000-1)
|
||||||
|
CERC_LACONICD_CHAIN_ID=
|
||||||
|
|
||||||
|
# Amount of tokens to transfer on a single request (default: 1000000)
|
||||||
|
CERC_TRANSFER_AMOUNT=
|
||||||
|
|
||||||
|
# Daily limit for transfer amount for an address (default: 3000000) (3 requests per day)
|
||||||
|
CERC_DAILY_LIMIT=
|
||||||
```
|
```
|
||||||
|
|
||||||
## Start the deployment
|
## Start the deployment
|
||||||
* To start the deployment:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
laconic-so deployment --dir laconic-faucet-deployment start
|
laconic-so deployment --dir laconic-faucet-deployment start
|
||||||
@ -85,12 +88,14 @@ Instructions for running the laconic faucet server
|
|||||||
docker logs -f <CONTAINER_ID>
|
docker logs -f <CONTAINER_ID>
|
||||||
```
|
```
|
||||||
|
|
||||||
* Request tokens from the testnet faucet for your account if required
|
## Run
|
||||||
|
|
||||||
|
* Request tokens from the faucet for an account:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -X POST http://localhost:3000/faucet \
|
curl -X POST http://localhost:3000/faucet \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"address": "<laconicd_address>"}'
|
-d '{"address": "<laconicd_address>"}'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Clean up
|
## Clean up
|
||||||
@ -98,7 +103,7 @@ Instructions for running the laconic faucet server
|
|||||||
* Stop the `laconic-faucet` service running in the background:
|
* Stop the `laconic-faucet` service running in the background:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Stop the docker containe
|
# Stop the docker container
|
||||||
laconic-so deployment --dir laconic-faucet-deployment stop
|
laconic-so deployment --dir laconic-faucet-deployment stop
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user