Skip to content

Commit

Permalink
Add support for captive core (standalone) and manual close
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Oct 27, 2020
1 parent 14188af commit 9b9f179
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 3 deletions.
3 changes: 3 additions & 0 deletions common/horizon/etc/horizon.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ export NETWORK_PASSPHRASE="__NETWORK__"
export DISABLE_ASSET_STATS="true"
export HISTORY_ARCHIVE_URLS="__ARCHIVE__"
export ADMIN_PORT=6060
export ENABLE_CAPTIVE_CORE_INGESTION=__ENABLE_CAPTIVE_CORE__
export STELLAR_CORE_BINARY_PATH=/usr/bin/stellar-core
export STELLAR_CORE_CONFIG_PATH=/opt/stellar/core/etc/stellar-captive-core.cfg
1 change: 1 addition & 0 deletions pubnet/core/etc/stellar-core.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
HTTP_PORT=11626
PUBLIC_HTTP_PORT=true
LOG_FILE_PATH=""
MANUAL_CLOSE=__MANUAL_CLOSE__

DATABASE="postgresql://dbname=core host=localhost user=stellar password=__PGPASS__"
NETWORK_PASSPHRASE="Public Global Stellar Network ; September 2015"
Expand Down
23 changes: 23 additions & 0 deletions standalone/core/etc/stellar-captive-core.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# simple captive core configuration for a standalone test "network"
NETWORK_PASSPHRASE="Standalone Network ; February 2017"
# for debugging purposes
HTTP_PORT=21626
# To avoid conflicts with the core instance
PEER_PORT=21625

NODE_IS_VALIDATOR=false
UNSAFE_QUORUM=true
FAILURE_SAFETY=0

DATABASE="sqlite3://stellar-captive-core.db"

COMMANDS=["ll?level=info"]

[[VALIDATORS]]
NAME="local_core"
HOME_DOMAIN="core.local"
# From "SDQVDISRYN2JXBS7ICL7QJAEKB3HWBJFP2QECXG7GZICAHBK4UNJCWK2"
PUBLIC_KEY="GCTI6HMWRH2QGMFKWVU5M5ZSOTKL7P7JAHZDMJJBKDHGWTEC4CJ7O3DU"
ADDRESS="localhost"
QUALITY="MEDIUM"
HISTORY="curl http://localhost:1570/{0} -o {1}"
5 changes: 3 additions & 2 deletions standalone/core/etc/stellar-core.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

HTTP_PORT=11626
PUBLIC_HTTP_PORT=true
RUN_STANDALONE=true
RUN_STANDALONE=__RUN_STANDALONE__
MANUAL_CLOSE=__MANUAL_CLOSE__

NETWORK_PASSPHRASE="Standalone Network ; February 2017"
KNOWN_CURSORS=["HORIZON"]
Expand All @@ -26,4 +27,4 @@ VALIDATORS=["$self"]
[HISTORY.vs]
get="cp /tmp/stellar-core/history/vs/{0} {1}"
put="cp {0} /tmp/stellar-core/history/vs/{1}"
mkdir="mkdir -p /tmp/stellar-core/history/vs/{0}"
mkdir="mkdir -p /tmp/stellar-core/history/vs/{0}"
22 changes: 21 additions & 1 deletion start
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export PGDATA="$PGHOME/data"
export PGUSER="stellar"
export PGPORT=5432

ENABLE_HORIZON_CAPTIVE_CORE=false
ENABLE_CORE_MANUAL_CLOSE=false

QUICKSTART_INITIALIZED=false
CURRENT_POSTGRES_PID=""

Expand All @@ -21,6 +24,10 @@ function main() {
echo ""

process_args $*
if [ "$NETWORK" != "standalone" ] && [ "$ENABLE_HORIZON_CAPTIVE_CORE" = "true" ]; then
echo "--enable-horizon-captive-core is only supported in the standalone network" >&2
exit 1
fi

echo "mode: $STELLAR_MODE"
echo "network: $NETWORK ($NETWORK_PASSPHRASE)"
Expand Down Expand Up @@ -60,6 +67,12 @@ function process_args() {
--enable-asset-stats)
export ENABLE_ASSET_STATS="$1"
shift
;;
--enable-horizon-captive-core)
ENABLE_HORIZON_CAPTIVE_CORE=true
;;
--enable-core-manual-close)
ENABLE_CORE_MANUAL_CLOSE=true
;;
*)
echo "Unknown container arg $ARG" >&2
Expand Down Expand Up @@ -230,7 +243,13 @@ function init_stellar_core() {
return 0
fi

run_silent "finalize-core-config" sed -ri "s/__PGPASS__/$PGPASS/g" etc/stellar-core.cfg
run_silent "finalize-core-config-pgpass" sed -ri "s/__PGPASS__/$PGPASS/g" etc/stellar-core.cfg
local RUN_STANDALONE=false
if [ "$NETWORK" = "standalone" ] && [ "$HORIZON_ENABLE_CAPTIVE_CORE" = "false" ]; then
RUN_STANDALONE=true
fi
run_silent "finalize-core-config-run-standalone" sed -ri "s/__RUN_STANDALONE__/$RUN_STANDALONE/g" etc/stellar-core.cfg
run_silent "finalize-core-config-manual-close" sed -ri "s/__MANUAL_CLOSE__/$ENABLE_CORE_MANUAL_CLOSE/g" etc/stellar-core.cfg

start_postgres

Expand Down Expand Up @@ -263,6 +282,7 @@ function init_horizon() {
-e "s/__PGPASS__/$PGPASS/g" \
-e "s/__NETWORK__/$NETWORK_PASSPHRASE/g" \
-e "s=__ARCHIVE__=$HISTORY_ARCHIVE_URLS=g" \
-e "s=__ENABLE_CAPTIVE_CORE__=$ENABLE_HORIZON_CAPTIVE_CORE=g" \
etc/horizon.env

start_postgres
Expand Down
1 change: 1 addition & 0 deletions testnet/core/etc/stellar-core.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
HTTP_PORT=11626
PUBLIC_HTTP_PORT=true
LOG_FILE_PATH=""
MANUAL_CLOSE=__MANUAL_CLOSE__

NETWORK_PASSPHRASE="Test SDF Network ; September 2015"
KNOWN_CURSORS=["HORIZON"]
Expand Down

0 comments on commit 9b9f179

Please sign in to comment.