start stack from container (#40)
resolves #36 Co-authored-by: johba <johba@harb.eth> Reviewed-on: https://codeberg.org/johba/harb/pulls/40
This commit is contained in:
parent
3a7162462b
commit
4f7cebda56
10 changed files with 160 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -11,6 +11,7 @@ out/
|
||||||
.env
|
.env
|
||||||
.secret
|
.secret
|
||||||
.secret*
|
.secret*
|
||||||
|
!onchain/.secret.local
|
||||||
.infura
|
.infura
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,25 @@ if ! command -v jq >/dev/null 2>&1; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ROOT_DIR=/workspace
|
ROOT_DIR=/workspace
|
||||||
|
GIT_BRANCH="${GIT_BRANCH:-}"
|
||||||
|
|
||||||
|
# Checkout branch if specified
|
||||||
|
if [[ -n "$GIT_BRANCH" ]]; then
|
||||||
|
cd "$ROOT_DIR"
|
||||||
|
git config --global --add safe.directory "$ROOT_DIR" 2>/dev/null || true
|
||||||
|
CURRENT=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")
|
||||||
|
|
||||||
|
if [[ "$CURRENT" != "$GIT_BRANCH" ]]; then
|
||||||
|
echo "[bootstrap] Switching to branch: $GIT_BRANCH"
|
||||||
|
# Try local branch first, then remote
|
||||||
|
if git rev-parse --verify "$GIT_BRANCH" >/dev/null 2>&1; then
|
||||||
|
git checkout "$GIT_BRANCH" 2>/dev/null || echo "[bootstrap] WARNING: Could not checkout $GIT_BRANCH"
|
||||||
|
else
|
||||||
|
git fetch origin "$GIT_BRANCH" 2>/dev/null || true
|
||||||
|
git checkout "$GIT_BRANCH" 2>/dev/null || echo "[bootstrap] WARNING: Could not checkout $GIT_BRANCH"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
STATE_DIR=$ROOT_DIR/tmp/podman
|
STATE_DIR=$ROOT_DIR/tmp/podman
|
||||||
LOG_DIR=$STATE_DIR/logs
|
LOG_DIR=$STATE_DIR/logs
|
||||||
SETUP_LOG=$LOG_DIR/setup.log
|
SETUP_LOG=$LOG_DIR/setup.log
|
||||||
|
|
@ -28,10 +47,6 @@ DEFAULT_DEPLOYER_ADDR=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
|
||||||
DEPLOYER_PK=${DEPLOYER_PK:-$DEFAULT_DEPLOYER_PK}
|
DEPLOYER_PK=${DEPLOYER_PK:-$DEFAULT_DEPLOYER_PK}
|
||||||
DEPLOYER_ADDR=${DEPLOYER_ADDR:-$DEFAULT_DEPLOYER_ADDR}
|
DEPLOYER_ADDR=${DEPLOYER_ADDR:-$DEFAULT_DEPLOYER_ADDR}
|
||||||
|
|
||||||
DEFAULT_TXNBOT_PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
|
|
||||||
DEFAULT_TXNBOT_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8
|
|
||||||
TXNBOT_PRIVATE_KEY=${TXNBOT_PRIVATE_KEY:-$DEFAULT_TXNBOT_PRIVATE_KEY}
|
|
||||||
TXNBOT_ADDRESS=${TXNBOT_ADDRESS:-$DEFAULT_TXNBOT_ADDRESS}
|
|
||||||
TXNBOT_FUND_VALUE=${TXNBOT_FUND_VALUE:-1ether}
|
TXNBOT_FUND_VALUE=${TXNBOT_FUND_VALUE:-1ether}
|
||||||
|
|
||||||
log() {
|
log() {
|
||||||
|
|
@ -67,6 +82,23 @@ maybe_set_deployer_from_mnemonic() {
|
||||||
DEPLOYER_ADDR=${DEPLOYER_ADDR:-$DEFAULT_DEPLOYER_ADDR}
|
DEPLOYER_ADDR=${DEPLOYER_ADDR:-$DEFAULT_DEPLOYER_ADDR}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
derive_txnbot_wallet() {
|
||||||
|
if [[ -f "$MNEMONIC_FILE" ]]; then
|
||||||
|
local mnemonic
|
||||||
|
mnemonic="$(tr -d '\n\r' <"$MNEMONIC_FILE")"
|
||||||
|
if [[ -n "$mnemonic" ]]; then
|
||||||
|
TXNBOT_PRIVATE_KEY="$(cast wallet private-key --mnemonic "$mnemonic" --mnemonic-index 2)"
|
||||||
|
TXNBOT_ADDRESS="$(cast wallet address --private-key "$TXNBOT_PRIVATE_KEY")"
|
||||||
|
log "Derived txnBot wallet: $TXNBOT_ADDRESS (account index 2)"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
# Fallback to hardcoded Anvil account 1
|
||||||
|
TXNBOT_PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
|
||||||
|
TXNBOT_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8
|
||||||
|
log "Using default txnBot wallet: $TXNBOT_ADDRESS"
|
||||||
|
}
|
||||||
|
|
||||||
run_forge_script() {
|
run_forge_script() {
|
||||||
log "Deploying contracts to fork"
|
log "Deploying contracts to fork"
|
||||||
pushd "$ROOT_DIR/onchain" >/dev/null
|
pushd "$ROOT_DIR/onchain" >/dev/null
|
||||||
|
|
@ -191,6 +223,7 @@ main() {
|
||||||
log "Waiting for Anvil"
|
log "Waiting for Anvil"
|
||||||
wait_for_rpc
|
wait_for_rpc
|
||||||
maybe_set_deployer_from_mnemonic
|
maybe_set_deployer_from_mnemonic
|
||||||
|
derive_txnbot_wallet
|
||||||
run_forge_script
|
run_forge_script
|
||||||
extract_addresses
|
extract_addresses
|
||||||
fund_liquidity_manager
|
fund_liquidity_manager
|
||||||
|
|
@ -206,6 +239,7 @@ main() {
|
||||||
log "Kraiken: $KRAIKEN"
|
log "Kraiken: $KRAIKEN"
|
||||||
log "Stake: $STAKE"
|
log "Stake: $STAKE"
|
||||||
log "LiquidityManager: $LIQUIDITY_MANAGER"
|
log "LiquidityManager: $LIQUIDITY_MANAGER"
|
||||||
|
log "txnBot: $TXNBOT_ADDRESS"
|
||||||
wait $prime_pid
|
wait $prime_pid
|
||||||
log "Block mining complete"
|
log "Block mining complete"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,26 @@
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
ROOT_DIR=/workspace
|
ROOT_DIR=/workspace
|
||||||
|
GIT_BRANCH="${GIT_BRANCH:-}"
|
||||||
|
|
||||||
|
# Checkout branch if specified
|
||||||
|
if [[ -n "$GIT_BRANCH" ]]; then
|
||||||
|
cd "$ROOT_DIR"
|
||||||
|
git config --global --add safe.directory "$ROOT_DIR" 2>/dev/null || true
|
||||||
|
CURRENT=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")
|
||||||
|
|
||||||
|
if [[ "$CURRENT" != "$GIT_BRANCH" ]]; then
|
||||||
|
echo "[landing-entrypoint] Switching to branch: $GIT_BRANCH"
|
||||||
|
# Try local branch first, then remote
|
||||||
|
if git rev-parse --verify "$GIT_BRANCH" >/dev/null 2>&1; then
|
||||||
|
git checkout "$GIT_BRANCH" 2>/dev/null || echo "[landing-entrypoint] WARNING: Could not checkout $GIT_BRANCH"
|
||||||
|
else
|
||||||
|
git fetch origin "$GIT_BRANCH" 2>/dev/null || true
|
||||||
|
git checkout "$GIT_BRANCH" 2>/dev/null || echo "[landing-entrypoint] WARNING: Could not checkout $GIT_BRANCH"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
LANDING_DIR=$ROOT_DIR/landing
|
LANDING_DIR=$ROOT_DIR/landing
|
||||||
REQUIRED_DIST="$ROOT_DIR/kraiken-lib/dist/index.js"
|
REQUIRED_DIST="$ROOT_DIR/kraiken-lib/dist/index.js"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,26 @@
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
ROOT_DIR=/workspace
|
ROOT_DIR=/workspace
|
||||||
|
GIT_BRANCH="${GIT_BRANCH:-}"
|
||||||
|
|
||||||
|
# Checkout branch if specified
|
||||||
|
if [[ -n "$GIT_BRANCH" ]]; then
|
||||||
|
cd "$ROOT_DIR"
|
||||||
|
git config --global --add safe.directory "$ROOT_DIR" 2>/dev/null || true
|
||||||
|
CURRENT=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")
|
||||||
|
|
||||||
|
if [[ "$CURRENT" != "$GIT_BRANCH" ]]; then
|
||||||
|
echo "[ponder-entrypoint] Switching to branch: $GIT_BRANCH"
|
||||||
|
# Try local branch first, then remote
|
||||||
|
if git rev-parse --verify "$GIT_BRANCH" >/dev/null 2>&1; then
|
||||||
|
git checkout "$GIT_BRANCH" 2>/dev/null || echo "[ponder-entrypoint] WARNING: Could not checkout $GIT_BRANCH"
|
||||||
|
else
|
||||||
|
git fetch origin "$GIT_BRANCH" 2>/dev/null || true
|
||||||
|
git checkout "$GIT_BRANCH" 2>/dev/null || echo "[ponder-entrypoint] WARNING: Could not checkout $GIT_BRANCH"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
CONTRACT_ENV=$ROOT_DIR/tmp/podman/contracts.env
|
CONTRACT_ENV=$ROOT_DIR/tmp/podman/contracts.env
|
||||||
PONDER_WORKDIR=$ROOT_DIR/services/ponder
|
PONDER_WORKDIR=$ROOT_DIR/services/ponder
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,26 @@
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
ROOT_DIR=/workspace
|
ROOT_DIR=/workspace
|
||||||
|
GIT_BRANCH="${GIT_BRANCH:-}"
|
||||||
|
|
||||||
|
# Checkout branch if specified
|
||||||
|
if [[ -n "$GIT_BRANCH" ]]; then
|
||||||
|
cd "$ROOT_DIR"
|
||||||
|
git config --global --add safe.directory "$ROOT_DIR" 2>/dev/null || true
|
||||||
|
CURRENT=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")
|
||||||
|
|
||||||
|
if [[ "$CURRENT" != "$GIT_BRANCH" ]]; then
|
||||||
|
echo "[txn-bot-entrypoint] Switching to branch: $GIT_BRANCH"
|
||||||
|
# Try local branch first, then remote
|
||||||
|
if git rev-parse --verify "$GIT_BRANCH" >/dev/null 2>&1; then
|
||||||
|
git checkout "$GIT_BRANCH" 2>/dev/null || echo "[txn-bot-entrypoint] WARNING: Could not checkout $GIT_BRANCH"
|
||||||
|
else
|
||||||
|
git fetch origin "$GIT_BRANCH" 2>/dev/null || true
|
||||||
|
git checkout "$GIT_BRANCH" 2>/dev/null || echo "[txn-bot-entrypoint] WARNING: Could not checkout $GIT_BRANCH"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
TXNBOT_ENV_FILE=$ROOT_DIR/tmp/podman/txnBot.env
|
TXNBOT_ENV_FILE=$ROOT_DIR/tmp/podman/txnBot.env
|
||||||
BOT_DIR=$ROOT_DIR/services/txnBot
|
BOT_DIR=$ROOT_DIR/services/txnBot
|
||||||
REQUIRED_DIST=$ROOT_DIR/kraiken-lib/dist/index.js
|
REQUIRED_DIST=$ROOT_DIR/kraiken-lib/dist/index.js
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,26 @@
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
ROOT_DIR=/workspace
|
ROOT_DIR=/workspace
|
||||||
|
GIT_BRANCH="${GIT_BRANCH:-}"
|
||||||
|
|
||||||
|
# Checkout branch if specified
|
||||||
|
if [[ -n "$GIT_BRANCH" ]]; then
|
||||||
|
cd "$ROOT_DIR"
|
||||||
|
git config --global --add safe.directory "$ROOT_DIR" 2>/dev/null || true
|
||||||
|
CURRENT=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")
|
||||||
|
|
||||||
|
if [[ "$CURRENT" != "$GIT_BRANCH" ]]; then
|
||||||
|
echo "[webapp-entrypoint] Switching to branch: $GIT_BRANCH"
|
||||||
|
# Try local branch first, then remote
|
||||||
|
if git rev-parse --verify "$GIT_BRANCH" >/dev/null 2>&1; then
|
||||||
|
git checkout "$GIT_BRANCH" 2>/dev/null || echo "[webapp-entrypoint] WARNING: Could not checkout $GIT_BRANCH"
|
||||||
|
else
|
||||||
|
git fetch origin "$GIT_BRANCH" 2>/dev/null || true
|
||||||
|
git checkout "$GIT_BRANCH" 2>/dev/null || echo "[webapp-entrypoint] WARNING: Could not checkout $GIT_BRANCH"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
CONTRACT_ENV=$ROOT_DIR/tmp/podman/contracts.env
|
CONTRACT_ENV=$ROOT_DIR/tmp/podman/contracts.env
|
||||||
APP_DIR=$ROOT_DIR/web-app
|
APP_DIR=$ROOT_DIR/web-app
|
||||||
SWAP_ROUTER=0x94cC0AaC535CCDB3C01d6787D6413C739ae12bc4
|
SWAP_ROUTER=0x94cC0AaC535CCDB3C01d6787D6413C739ae12bc4
|
||||||
|
|
|
||||||
14
docs/test-accounts.md
Normal file
14
docs/test-accounts.md
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
# Test Accounts
|
||||||
|
|
||||||
|
Mnemonic: `test test test test test test test test test test test junk`
|
||||||
|
|
||||||
|
All accounts receive 10000 ETH on Anvil startup.
|
||||||
|
|
||||||
|
| Index | Address | Purpose |
|
||||||
|
|-------|---------|---------|
|
||||||
|
| 0 | 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 | Deployer |
|
||||||
|
| 1 | 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 | LiquidityManager Operator |
|
||||||
|
| 2 | 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC | txnBot |
|
||||||
|
| 3 | 0x90F79bf6EB2c4f870365E785982E1f101E93b906 | Test User |
|
||||||
|
|
||||||
|
**Funding**: Use `/cheap` on webapp for Base Sepolia testnet.
|
||||||
1
onchain/.secret.local
Normal file
1
onchain/.secret.local
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
test test test test test test test test test test test junk
|
||||||
|
|
@ -39,8 +39,10 @@ services:
|
||||||
command: ["/workspace/containers/bootstrap.sh"]
|
command: ["/workspace/containers/bootstrap.sh"]
|
||||||
volumes:
|
volumes:
|
||||||
- .:/workspace:z
|
- .:/workspace:z
|
||||||
|
- .git:/workspace/.git:ro,z
|
||||||
environment:
|
environment:
|
||||||
- ANVIL_RPC=http://anvil:8545
|
- ANVIL_RPC=http://anvil:8545
|
||||||
|
- GIT_BRANCH=${GIT_BRANCH:-}
|
||||||
depends_on:
|
depends_on:
|
||||||
anvil:
|
anvil:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|
@ -60,11 +62,13 @@ services:
|
||||||
entrypoint: ["/workspace/containers/ponder-dev-entrypoint.sh"]
|
entrypoint: ["/workspace/containers/ponder-dev-entrypoint.sh"]
|
||||||
volumes:
|
volumes:
|
||||||
- .:/workspace:z
|
- .:/workspace:z
|
||||||
|
- .git:/workspace/.git:ro,z
|
||||||
- ./kraiken-lib/dist:/workspace/kraiken-lib/dist:ro,z
|
- ./kraiken-lib/dist:/workspace/kraiken-lib/dist:ro,z
|
||||||
- ponder-node-modules:/workspace/services/ponder/node_modules
|
- ponder-node-modules:/workspace/services/ponder/node_modules
|
||||||
working_dir: /workspace
|
working_dir: /workspace
|
||||||
environment:
|
environment:
|
||||||
- CHOKIDAR_USEPOLLING=1
|
- CHOKIDAR_USEPOLLING=1
|
||||||
|
- GIT_BRANCH=${GIT_BRANCH:-}
|
||||||
depends_on:
|
depends_on:
|
||||||
anvil:
|
anvil:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|
@ -89,11 +93,13 @@ services:
|
||||||
entrypoint: ["/workspace/containers/webapp-dev-entrypoint.sh"]
|
entrypoint: ["/workspace/containers/webapp-dev-entrypoint.sh"]
|
||||||
volumes:
|
volumes:
|
||||||
- .:/workspace:z
|
- .:/workspace:z
|
||||||
|
- .git:/workspace/.git:ro,z
|
||||||
- ./kraiken-lib/dist:/workspace/kraiken-lib/dist:ro,z
|
- ./kraiken-lib/dist:/workspace/kraiken-lib/dist:ro,z
|
||||||
- webapp-node-modules:/workspace/web-app/node_modules
|
- webapp-node-modules:/workspace/web-app/node_modules
|
||||||
working_dir: /workspace
|
working_dir: /workspace
|
||||||
environment:
|
environment:
|
||||||
- CHOKIDAR_USEPOLLING=1
|
- CHOKIDAR_USEPOLLING=1
|
||||||
|
- GIT_BRANCH=${GIT_BRANCH:-}
|
||||||
depends_on:
|
depends_on:
|
||||||
ponder:
|
ponder:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|
@ -113,11 +119,13 @@ services:
|
||||||
entrypoint: ["/workspace/containers/landing-dev-entrypoint.sh"]
|
entrypoint: ["/workspace/containers/landing-dev-entrypoint.sh"]
|
||||||
volumes:
|
volumes:
|
||||||
- .:/workspace:z
|
- .:/workspace:z
|
||||||
|
- .git:/workspace/.git:ro,z
|
||||||
- ./kraiken-lib/dist:/workspace/kraiken-lib/dist:ro,z
|
- ./kraiken-lib/dist:/workspace/kraiken-lib/dist:ro,z
|
||||||
- landing-node-modules:/workspace/landing/node_modules
|
- landing-node-modules:/workspace/landing/node_modules
|
||||||
working_dir: /workspace
|
working_dir: /workspace
|
||||||
environment:
|
environment:
|
||||||
- CHOKIDAR_USEPOLLING=1
|
- CHOKIDAR_USEPOLLING=1
|
||||||
|
- GIT_BRANCH=${GIT_BRANCH:-}
|
||||||
depends_on:
|
depends_on:
|
||||||
ponder:
|
ponder:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|
@ -137,10 +145,13 @@ services:
|
||||||
entrypoint: ["/workspace/containers/txn-bot-entrypoint.sh"]
|
entrypoint: ["/workspace/containers/txn-bot-entrypoint.sh"]
|
||||||
volumes:
|
volumes:
|
||||||
- .:/workspace:z
|
- .:/workspace:z
|
||||||
|
- .git:/workspace/.git:ro,z
|
||||||
- ./kraiken-lib/dist:/workspace/kraiken-lib/dist:ro,z
|
- ./kraiken-lib/dist:/workspace/kraiken-lib/dist:ro,z
|
||||||
- txn-node-modules:/workspace/services/txnBot/node_modules
|
- txn-node-modules:/workspace/services/txnBot/node_modules
|
||||||
- kraiken-node-modules:/workspace/kraiken-lib/node_modules
|
- kraiken-node-modules:/workspace/kraiken-lib/node_modules
|
||||||
working_dir: /workspace
|
working_dir: /workspace
|
||||||
|
environment:
|
||||||
|
- GIT_BRANCH=${GIT_BRANCH:-}
|
||||||
depends_on:
|
depends_on:
|
||||||
ponder:
|
ponder:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,11 @@ start_stack() {
|
||||||
rm -f "$PID_FILE"
|
rm -f "$PID_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Show branch if set
|
||||||
|
if [[ -n "${GIT_BRANCH:-}" ]]; then
|
||||||
|
echo "Branch: $GIT_BRANCH"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Building kraiken-lib..."
|
echo "Building kraiken-lib..."
|
||||||
./scripts/build-kraiken-lib.sh
|
./scripts/build-kraiken-lib.sh
|
||||||
|
|
||||||
|
|
@ -71,7 +76,16 @@ check_health() {
|
||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $0 {start|stop|health}"
|
cat <<EOF
|
||||||
|
Usage: $0 {start|stop|health}
|
||||||
|
|
||||||
|
Environment Variables:
|
||||||
|
GIT_BRANCH Branch to checkout in containers
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
GIT_BRANCH=fix/something ./scripts/dev.sh start
|
||||||
|
./scripts/dev.sh health
|
||||||
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue