diff --git a/Dockerfile b/Dockerfile index 1da9ade..6b3ff3c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,8 +21,10 @@ RUN rm -rf /alephium-home/.alephium/user.conf COPY snapshot-loader.sh /snapshot-loader.sh COPY entrypoint-wrapper.sh /entrypoint-wrapper.sh -COPY user-mainnet.conf /user-mainnet.conf -COPY user-testnet.conf /user-testnet.conf +COPY user-mainnet-with-indexes.conf /user-mainnet-with-indexes.conf +COPY user-mainnet-without-indexes.conf /user-mainnet-without-indexes.conf +COPY user-testnet-with-indexes.conf /user-testnet-with-indexes.conf +COPY user-testnet-without-indexes.conf /user-testnet-without-indexes.conf EXPOSE 39973/tcp EXPOSE 39973/udp diff --git a/entrypoint-wrapper.sh b/entrypoint-wrapper.sh index 8a8ca5e..e8f2629 100755 --- a/entrypoint-wrapper.sh +++ b/entrypoint-wrapper.sh @@ -2,6 +2,7 @@ ALEPHIUM_HOME=${ALEPHIUM_HOME:-/alephium-home/.alephium} ALEPHIUM_NETWORK=${ALEPHIUM_NETWORK:-mainnet} +NODE_INDEXES_CONFIG=${NODE_INDEXES_CONFIG:-with-indexes} # Call snapshot-loader.sh and ensure it completed successfully, stopping the execution otherwise. if ! ./snapshot-loader.sh @@ -14,7 +15,7 @@ fi if [ ! -f "$ALEPHIUM_HOME/user.conf" ] then echo "Copying standalone user.conf file" - cp "/user-$ALEPHIUM_NETWORK.conf" "$ALEPHIUM_HOME/user.conf" + cp "/user-$ALEPHIUM_NETWORK-$NODE_INDEXES_CONFIG.conf" "$ALEPHIUM_HOME/user.conf" fi echo "Now starting Alephium full node!" diff --git a/snapshot-loader.sh b/snapshot-loader.sh index f4cc083..e6bc10f 100755 --- a/snapshot-loader.sh +++ b/snapshot-loader.sh @@ -5,17 +5,19 @@ ALEPHIUM_NETWORK=${ALEPHIUM_NETWORK:-mainnet} ALEPHIUM_FORCE_RELOAD_SNAPSHOT=${ALEPHIUM_FORCE_RELOAD_SNAPSHOT:-0} # Node type: full or pruned. Any other value might cause unexpected behaviour NODE_TYPE=${NODE_TYPE:-pruned} +NODE_INDEXES_CONFIG=${NODE_INDEXES_CONFIG:-with-indexes} # If tee-hash (https://github.com/touilleio/tee-hash) is available, validates the checksum of the downloaded file. # Do not validate the checksum otherwise TEE_HASH_CMD=$(which cat) VALIDATE_CHECKSUM=0 CHECKSUM_FILE=${CHECKSUM_FILE:-/var/tmp/sha256sum} -if which tee-hash >/dev/null -then - TEE_HASH_CMD="tee-hash --output ${CHECKSUM_FILE}" - VALIDATE_CHECKSUM=1 -fi +# TODO: Disable for now +#if which tee-hash >/dev/null +#then +# TEE_HASH_CMD="tee-hash --output ${CHECKSUM_FILE}" +# VALIDATE_CHECKSUM=1 +#fi # Check if ALEPHIUM_HOME folder is writable if [ ! -w "$ALEPHIUM_HOME" ] @@ -46,7 +48,7 @@ then # Check if enough disk space available availableSpace=$(df -B1 "$ALEPHIUM_HOME" | tail -n 1 | awk '{print $4}' | head -n 1) - neededSpace=$(curl -s -I -L "$(curl -sL https://archives.alephium.org/archives/$ALEPHIUM_NETWORK/${NODE_TYPE}-node-data/_latest.txt)" | grep -i 'Content-Length:' | awk '{print $2}' | tr -d '\r') + neededSpace=$(curl -s -I -L "$(curl -sL https://archives.alephium.org/archives/$ALEPHIUM_NETWORK/${NODE_TYPE}-node-data/_latest_$NODE_INDEXES_CONFIG.txt)" | grep -i 'Content-Length:' | awk '{print $2}' | tr -d '\r') neededSpaceWithMargin=$(echo "${neededSpace} * 1.2 / 1" | bc) neededSpaceInGB=$(echo "${neededSpaceWithMargin} / 1000 / 1000 / 1000 / 1" | bc) availableSpaceInGB=$(echo "${availableSpace} / 1000 / 1000 / 1000 / 1" | bc) @@ -59,7 +61,7 @@ then echo "Loading $ALEPHIUM_NETWORK snapshot from official https://archives.alephium.org" # Creating a temp folder (on the same volume) where snapshot will be loaded mkdir "$ALEPHIUM_HOME/${ALEPHIUM_NETWORK}-snapshot" - curl -L "$(curl -sL https://archives.alephium.org/archives/$ALEPHIUM_NETWORK/${NODE_TYPE}-node-data/_latest.txt)" | $TEE_HASH_CMD | tar xf - -C "$ALEPHIUM_HOME/${ALEPHIUM_NETWORK}-snapshot" + curl -L "$(curl -sL https://archives.alephium.org/archives/$ALEPHIUM_NETWORK/${NODE_TYPE}-node-data/_latest_$NODE_INDEXES_CONFIG.txt)" | $TEE_HASH_CMD | tar xf - -C "$ALEPHIUM_HOME/${ALEPHIUM_NETWORK}-snapshot" res=$? if [ "$res" != "0" ]; # If curl or tar command failed, stopping the load of the snapshot. then @@ -69,7 +71,7 @@ then if [ "${VALIDATE_CHECKSUM}" = "1" ] then # Check sha256 of what has been downloaded - remote_sha256sum="$(curl -sL https://archives.alephium.org/archives/$ALEPHIUM_NETWORK/${NODE_TYPE}-node-data/_latest.txt.sha256sum)" + remote_sha256sum="$(curl -sL https://archives.alephium.org/archives/$ALEPHIUM_NETWORK/${NODE_TYPE}-node-data/_latest_$NODE_INDEXES_CONFIG.txt.sha256sum)" local_sha256sum=$(cat "${CHECKSUM_FILE}") if [ "$remote_sha256sum" != "$local_sha256sum" ] then diff --git a/user-mainnet.conf b/user-mainnet-with-indexes.conf similarity index 78% rename from user-mainnet.conf rename to user-mainnet-with-indexes.conf index b4705b7..b49a6ac 100644 --- a/user-mainnet.conf +++ b/user-mainnet-with-indexes.conf @@ -7,3 +7,5 @@ alephium.api.api-key-enabled = false alephium.node.event-log.enabled=true alephium.node.event-log.index-by-tx-id = true alephium.node.event-log.index-by-block-hash = true +alephium.node.indexes.subcontract-index = true +alephium.node.indexes.tx-output-ref-index = true diff --git a/user-mainnet-without-indexes.conf b/user-mainnet-without-indexes.conf new file mode 100644 index 0000000..7cd6d8d --- /dev/null +++ b/user-mainnet-without-indexes.conf @@ -0,0 +1,7 @@ +alephium.network.network-id = 0 +alephium.network.bind-address = "0.0.0.0:39973" +alephium.api.network-interface = "0.0.0.0" +alephium.mining.api-interface = "0.0.0.0" +alephium.api.api-key-enabled = false + +alephium.node.event-log.enabled=false diff --git a/user-testnet.conf b/user-testnet-with-indexes.conf similarity index 82% rename from user-testnet.conf rename to user-testnet-with-indexes.conf index 82874f9..e207d76 100644 --- a/user-testnet.conf +++ b/user-testnet-with-indexes.conf @@ -8,3 +8,5 @@ alephium.api.api-key-enabled = false alephium.node.event-log.enabled=true alephium.node.event-log.index-by-tx-id = true alephium.node.event-log.index-by-block-hash = true +alephium.node.indexes.subcontract-index = true +alephium.node.indexes.tx-output-ref-index = true diff --git a/user-testnet-without-indexes.conf b/user-testnet-without-indexes.conf new file mode 100644 index 0000000..68e2631 --- /dev/null +++ b/user-testnet-without-indexes.conf @@ -0,0 +1,8 @@ +alephium.network.network-id = 1 +alephium.network.bind-address = "0.0.0.0:39973" +alephium.discovery.bootstrap = ["bootstrap0.testnet.alephium.org:9973", "bootstrap1.testnet.alephium.org:9973"] +alephium.api.network-interface = "0.0.0.0" +alephium.mining.api-interface = "0.0.0.0" +alephium.api.api-key-enabled = false + +alephium.node.event-log.enabled=false