Skip to content

Commit

Permalink
Sanchonet testnet deployemnt (#1700)
Browse files Browse the repository at this point in the history
## Description
- [x] Adds ability to deploy configuration files for sanchonet testnet
network using guild-deploy.
- [x] Add build automation for BLST in guild-deploy.sh

It does **NOT**:
- Deploy sanchonet compatible binaries.
- Update script commands to utilize the new format of cardano-cli
pre-release. Though current commands should be backwards compatible.

---------

Co-authored-by: RdLrT <[email protected]>
  • Loading branch information
Scitz0 and rdlrt authored Jan 8, 2024
1 parent a47f1c2 commit 61edfbd
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docs/Build/node-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ cd cardano-node
You can use the instructions below to build the latest release of [cardano-node](https://github.com/intersectmbo/cardano-node).

``` bash
git fetch --tags --all
git fetch --tags --recurse-submodules --all
git pull
# Replace tag against checkout if you do not want to build the latest released version
# Replace tag against checkout if you do not want to build the latest released version, we recommend using battle tested node versions - which may not always be latest
git checkout $(curl -sLf https://api.github.com/repos/intersectmbo/cardano-node/releases/latest | jq -r .tag_name)

# Use `-l` argument if you'd like to use system libsodium instead of IOG fork of libsodium while compiling
Expand Down
112 changes: 112 additions & 0 deletions files/config-sanchonet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"AlonzoGenesisFile": "/opt/cardano/cnode/files/alonzo-genesis.json",
"ApplicationName": "cardano-sl",
"ApplicationVersion": 0,
"ByronGenesisFile": "/opt/cardano/cnode/files/byron-genesis.json",
"ConwayGenesisFile": "/opt/cardano/cnode/files/conway-genesis.json",
"EnableP2P": true,
"ExperimentalHardForksEnabled": true,
"ExperimentalProtocolsEnabled": true,
"LastKnownBlockVersion-Alt": 0,
"LastKnownBlockVersion-Major": 3,
"LastKnownBlockVersion-Minor": 1,
"Protocol": "Cardano",
"RequiresNetworkMagic": "RequiresMagic",
"ShelleyGenesisFile": "/opt/cardano/cnode/files/shelley-genesis.json",
"TargetNumberOfActivePeers": 20,
"TargetNumberOfEstablishedPeers": 50,
"TargetNumberOfKnownPeers": 100,
"TargetNumberOfRootPeers": 100,
"TestAllegraHardForkAtEpoch": 0,
"TestAlonzoHardForkAtEpoch": 0,
"TestMaryHardForkAtEpoch": 0,
"TestShelleyHardForkAtEpoch": 0,
"EnableLogging": true,
"EnableLogMetrics": false,
"TraceAcceptPolicy": true,
"TraceBlockFetchClient": false,
"TraceBlockFetchDecisions": false,
"TraceBlockFetchProtocol": false,
"TraceBlockFetchProtocolSerialised": false,
"TraceBlockFetchServer": false,
"TraceChainDb": true,
"TraceChainSyncBlockServer": false,
"TraceChainSyncClient": false,
"TraceChainSyncHeaderServer": false,
"TraceChainSyncProtocol": false,
"TraceConnectionManager": true,
"TraceDNSResolver": true,
"TraceDNSSubscription": true,
"TraceDiffusionInitialization": true,
"TraceErrorPolicy": true,
"TraceForge": true,
"TraceHandshake": false,
"TraceInboundGovernor": true,
"TraceIpSubscription": true,
"TraceLedgerPeers": true,
"TraceLocalChainSyncProtocol": false,
"TraceLocalErrorPolicy": true,
"TraceLocalHandshake": false,
"TraceLocalRootPeers": true,
"TraceLocalTxSubmissionProtocol": false,
"TraceLocalTxSubmissionServer": false,
"TraceMempool": true,
"TraceMux": false,
"TracePeerSelection": true,
"TracePeerSelectionActions": true,
"TracePublicRootPeers": true,
"TraceServer": true,
"TraceTxInbound": false,
"TraceTxOutbound": false,
"TraceTxSubmissionProtocol": false,
"TracingVerbosity": "NormalVerbosity",
"TurnOnLogMetrics": true,
"TurnOnLogging": true,
"defaultBackends": [
"KatipBK"
],
"defaultScribes": [
[
"FileSK",
"/opt/cardano/cnode/logs/node0.json"
]
],
"hasEKG": 12788,
"hasPrometheus": [
"127.0.0.1",
12798
],
"minSeverity": "Info",
"options": {
"mapBackends": {
"cardano.node.metrics": [
"EKGViewBK"
],
"cardano.node.resources": [
"EKGViewBK"
]
},
"mapSubtrace": {
"cardano.node.metrics": {
"subtrace": "Neutral"
}
}
},
"rotation": {
"rpKeepFilesNum": 10,
"rpLogLimitBytes": 50000000,
"rpMaxAgeHours": 24
},
"setupBackends": [
"KatipBK",
"EKGViewBK"
],
"setupScribes": [
{
"scKind": "FileSK",
"scName": "/opt/cardano/cnode/logs/node0.json",
"scFormat": "ScJson",
"scRotation": null
}
]
}
13 changes: 8 additions & 5 deletions scripts/cnode-helper-scripts/env
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ getEraIdentifier() {
Mary) ERA_IDENTIFIER="--mary-era" ;;
Alonzo) ERA_IDENTIFIER="--alonzo-era" ;;
Babbage) ERA_IDENTIFIER="--babbage-era" ;;
*) ERA_IDENTIFIER="--babbage-era" # use mary era as default
*) ERA_IDENTIFIER="--babbage-era"
[[ ${OFFLINE_MODE} = "N" ]] && return 1
esac
return 0
Expand Down Expand Up @@ -1059,18 +1059,21 @@ case ${NWMAGIC} in
NETWORK_NAME="Mainnet"
SHELLEY_TRANS_EPOCH=208
[[ -z ${KOIOS_API} ]] && KOIOS_API="https://api.koios.rest/api/v1" ;;
141)
NETWORK_NAME="Guild"
SHELLEY_TRANS_EPOCH=2
[[ -z ${KOIOS_API} ]] && KOIOS_API="https://guild.koios.rest/api/v1";;
1)
NETWORK_NAME="PreProd"
SHELLEY_TRANS_EPOCH=4
[[ -z ${KOIOS_API} ]] && KOIOS_API="https://preprod.koios.rest/api/v1";;
141)
NETWORK_NAME="Guild"
SHELLEY_TRANS_EPOCH=2
[[ -z ${KOIOS_API} ]] && KOIOS_API="https://guild.koios.rest/api/v1";;
2)
NETWORK_NAME="Preview"
SHELLEY_TRANS_EPOCH=0
[[ -z ${KOIOS_API} ]] && KOIOS_API="https://preview.koios.rest/api/v1";;
4)
NETWORK_NAME="Sanchonet"
SHELLEY_TRANS_EPOCH=0;;
*)
NETWORK_NAME="Custom"
[[ -z ${SHELLEY_TRANS_EPOCH} ]] && SHELLEY_TRANS_EPOCH=0
Expand Down
41 changes: 37 additions & 4 deletions scripts/cnode-helper-scripts/guild-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ versionCheck() { printf '%s\n%s' "${1//v/}" "${2//v/}" | sort -C -V; } #$1=avail
usage() {
cat <<-EOF >&2
Usage: $(basename "$0") [-n <mainnet|preprod|guild|preview>] [-p path] [-t <name>] [-b <branch>] [-u] [-s [p][b][l][m][f][d][c][o][w][x]]
Usage: $(basename "$0") [-n <mainnet|guild|preprod|preview|sanchonet>] [-p path] [-t <name>] [-b <branch>] [-u] [-s [p][b][l][m][f][d][c][o][w][x]]
Set up dependencies for building/using common tools across cardano ecosystem.
The script will always update dynamic content from existing scripts retaining existing user variables
Expand Down Expand Up @@ -256,7 +256,7 @@ build_dependencies() {
echo -e "\nInstalling Haskell build/compiler dependencies (if missing)..."
export BOOTSTRAP_HASKELL_NO_UPGRADE=1
export BOOTSTRAP_HASKELL_GHC_VERSION=8.10.7
export BOOTSTRAP_HASKELL_CABAL_VERSION=3.10.1.0
export BOOTSTRAP_HASKELL_CABAL_VERSION=3.10.2.0
if ! command -v ghcup &>/dev/null; then
echo -e "\nInstalling ghcup (The Haskell Toolchain installer) .."
BOOTSTRAP_HASKELL_NONINTERACTIVE=1
Expand Down Expand Up @@ -301,6 +301,7 @@ build_dependencies() {
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
fi
echo -e "\nlibsecp256k1 installed to /usr/local/lib/"
build_libblst
}

# Build fork of libsodium
Expand All @@ -322,6 +323,38 @@ build_libsodium() {
echo -e "\nIOG fork of libsodium installed to /usr/local/lib/"
}

build_libblst() {
echo -e "\nBuilding BLST..."
if ! grep -q "/usr/local/lib:\$LD_LIBRARY_PATH" "${HOME}"/.bashrc; then
echo -e "\nexport LD_LIBRARY_PATH=/usr/local/lib:\$LD_LIBRARY_PATH" >> "${HOME}"/.bashrc
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
fi
pushd "${HOME}"/git >/dev/null || err_exit
[[ ! -d "./blst" ]] && git clone https://github.com/supranational/blst &>/dev/null
pushd blst >/dev/null || err_exit
git fetch >/dev/null 2>&1
git checkout v0.3.10 &>/dev/null
./build.sh >/dev/null 2>&1
cat <<-EOF >libblst.pc
prefix=/usr/local
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include
Name: libblst
Description: Multilingual BLS12-381 signature library
URL: https://github.com/supranational/blst
Version: 0.3.10
Cflags: -I\${includedir}
Libs: -L\${libdir} -lblst
EOF
[[ ! -d /usr/local/lib/pkgconfig ]] && $sudo mkdir -p /usr/local/lib/pkgconfig
$sudo cp -f libblst.pc /usr/local/lib/pkgconfig/
$sudo cp bindings/blst_aux.h bindings/blst.h bindings/blst.hpp /usr/local/include/
$sudo cp libblst.a /usr/local/lib
$sudo chmod u=rw,go=r /usr/local/{lib/{libblst.a,pkgconfig/libblst.pc},include/{blst.{h,hpp},blst_aux.h}}
}

# Download cardano-node, cardano-cli, cardano-db-sync, bech32 and cardano-submit-api
# TODO: Replace these with self-hosted ones (potentially consider IPFS as upload destination for CI)
download_cnodebins() {
Expand Down Expand Up @@ -541,7 +574,7 @@ populate_cnode() {
curl -sL -f -m ${CURL_TIMEOUT} -o conway-genesis.json.tmp ${URL_RAW}/files/conway-genesis-guild.json || err_exit "${err_msg} conway-genesis-guild.json"
curl -sL -f -m ${CURL_TIMEOUT} -o topology.json.tmp ${URL_RAW}/files/topology-guild.json || err_exit "${err_msg} topology-guild.json"
curl -sL -f -m ${CURL_TIMEOUT} -o config.json.tmp ${URL_RAW}/files/config-guild.json || err_exit "${err_msg} config-guild.json"
elif [[ ${NETWORK} =~ ^(mainnet|preprod|preview)$ ]]; then
elif [[ ${NETWORK} =~ ^(mainnet|preprod|preview|sanchonet)$ ]]; then
NWCONFURL="https://raw.githubusercontent.com/intersectmbo/cardano-world/master/docs/environments"
curl -sL -f -m ${CURL_TIMEOUT} -o byron-genesis.json.tmp "${NWCONFURL}/${NETWORK}/byron-genesis.json" || err_exit "${err_msg} byron-genesis.json"
curl -sL -f -m ${CURL_TIMEOUT} -o shelley-genesis.json.tmp "${NWCONFURL}/${NETWORK}/shelley-genesis.json" || err_exit "${err_msg} shelley-genesis.json"
Expand All @@ -550,7 +583,7 @@ populate_cnode() {
curl -sL -f -m ${CURL_TIMEOUT} -o topology.json.tmp "${NWCONFURL}/${NETWORK}/topology.json" || err_exit "${err_msg} topology.json"
curl -sL -f -m ${CURL_TIMEOUT} -o config.json.tmp "${URL_RAW}/files/config-${NETWORK}.json" || err_exit "${err_msg} config-${NETWORK}.json"
else
err_exit "Unknown network specified! Kindly re-check the network name, valid options are: mainnet, preprod, guild or preview."
err_exit "Unknown network specified! Kindly re-check the network name, valid options are: mainnet, guild, preprod, preview or sanchonet."
fi
sed -e "s@/opt/cardano/cnode@${CNODE_HOME}@g" -i ./*.json.tmp
if [[ ${FORCE_OVERWRITE} = 'Y' ]]; then
Expand Down

0 comments on commit 61edfbd

Please sign in to comment.