Skip to content

Commit

Permalink
merge changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nilaysaha committed Aug 10, 2024
2 parents e8db527 + e566e2b commit 445c8f0
Show file tree
Hide file tree
Showing 44 changed files with 35,478 additions and 13,348 deletions.
14 changes: 6 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ ENV PATH=${PATH}:/root/.ghcup/bin

# Install cabal
RUN bash -c "ghcup upgrade"
RUN bash -c "ghcup install cabal 3.6.2.0"
RUN bash -c "ghcup set cabal 3.6.2.0"
RUN bash -c "ghcup install cabal 3.8.1.0"
RUN bash -c "ghcup set cabal 3.8.1.0"

# Install GHC
RUN bash -c "ghcup install ghc 8.10.7"
Expand Down Expand Up @@ -81,10 +81,10 @@ RUN echo `which cabal`
# make install;


#install libsodium
#install libsodium (earlier: 66f017f1)
RUN git clone https://github.com/input-output-hk/libsodium; \
cd libsodium; \
git checkout 66f017f1; \
git checkout dbb48cce5429cb6585c9034f002568964f1ce567; \
./autogen.sh; \
./configure; \
make; \
Expand All @@ -108,23 +108,21 @@ RUN git clone https://github.com/bitcoin-core/secp256k1.git; \
RUN echo "with-compiler: ghc-8.10.7" >> cabal.project.local

#Now import the cardano-node
RUN git clone https://github.com/input-output-hk/cardano-node.git; \
RUN git clone https://github.com/IntersectMBO/cardano-node.git; \
cd cardano-node; \
cabal clean; \
cabal update;\
git fetch -all --tags; \
git fetch --all --recurse-submodules --tags; \
git checkout ${CARDANO_NODE_VERSION} -b tag-${CARDANO_NODE_VERSION};\
cabal build all;

ENV CARDANO_NODE_PATH="/cardano-node/dist-newstyle/build/x86_64-linux/ghc-8.10.7/cardano-node-${CARDANO_NODE_VERSION_EXPORT}/x/cardano-node/build/cardano-node/cardano-node"
ENV CARDANO_CLI_PATH="/cardano-node/dist-newstyle/build/x86_64-linux/ghc-8.10.7/cardano-cli-${CARDANO_NODE_VERSION_EXPORT}/x/cardano-cli/build/cardano-cli/cardano-cli"
ENV CARDANO_CHAIRMAN_PATH="/cardano-node/dist-newstyle/build/x86_64-linux/ghc-8.10.7/cardano-node-chairman-${CARDANO_NODE_VERSION_EXPORT}/x/cardano-node-chairman/build/cardano-node-chairman/cardano-node-chairman"

ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8

#Upload using api
RUN aws s3 cp ${CARDANO_NODE_PATH} s3://stake-pool/"cardano-node-${CARDANO_NODE_VERSION}"
RUN aws s3 cp ${CARDANO_CLI_PATH} s3://stake-pool/"cardano-cli-${CARDANO_NODE_VERSION}"
RUN aws s3 cp ${CARDANO_CHAIRMAN_PATH} s3://stake-pool/"cardano-node-chairman-${CARDANO_NODE_VERSION}"

Empty file modified exec/db-sync/db-sync.sh
100644 → 100755
Empty file.
8 changes: 4 additions & 4 deletions exec/ff-node-shelly-mainnet-relay.v2
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ ensure_node_dir() {
}

stop() {
pkill -2 cardano-node
pkill -15 cardano-node
}

choice() { i=$1; shift; eval "echo \${$((i + 1))}"; }

cexec() {
BASE_CONFIG="${SCRIPTDIR}/../src/tconfig/mainnet-config.json"
TOPOLOGY_CONFIG="${SCRIPTDIR}/../src/tconfig/mainnet-topology.json"
BASE_CONFIG="${SCRIPTDIR}/../src/tconfig/mainnet/config.json"
TOPOLOGY_CONFIG="${SCRIPTDIR}/../src/tconfig/mainnet/topology.json"
CARDANO_NODE="/home/nsaha/.cabal/bin/cardano-node"
HOST_IP="$(curl ipinfo.io/ip; echo)"
HOST_IP="$(hostname -I|cut -d' ' -f1)"
PORT=3001
DB_DIR="${NODE_DIR}/db-ff"
SOCKET="${NODE_DIR}/node.socket"
Expand Down
10 changes: 5 additions & 5 deletions exec/ff-node-shelly-mainnet.v2
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ ensure_node_dir() {
}

stop() {
kill -2 `pgrep -u nsaha cardano-node`
kill -15 `pgrep -u nsaha cardano-node`
}

choice() { i=$1; shift; eval "echo \${$((i + 1))}"; }

cexec() {
BASE_CONFG="${SCRIPTDIR}/../src/tconfig/mainnet-config.json"
TOPOLOGY_CONFIG="${SCRIPTDIR}/../src/tconfig/mainnet-topology.json"
GENESIS_CONFIG="${SCRIPTDIR}/../src/tconfig/mainnet-genesis.json"
BASE_CONFG="${SCRIPTDIR}/../src/tconfig/mainnet/config.json"
TOPOLOGY_CONFIG="${SCRIPTDIR}/../src/tconfig/mainnet/topology.json"
GENESIS_CONFIG="${SCRIPTDIR}/../src/tconfig/mainnet/genesis.json"
KES_SKEY="${SCRIPTDIR}/../src/kaddr_run/kes.skey"
VRF_SKEY="${SCRIPTDIR}/../src/kaddr_run/vrf.skey"
NODE_CERT="${SCRIPTDIR}/../src/kaddr_run/node.cert"

CARDANO_NODE="/home/nsaha/.cabal/bin/cardano-node"
HOST_IP="$(wget http://ipecho.net/plain -O - -q ; echo)"
HOST_IP="$(hostname -I|cut -d' ' -f1)"
PORT=3001
DB_DIR="${NODE_DIR}/db-ff"
SOCKET="${NODE_DIR}/node.socket"
Expand Down
8 changes: 4 additions & 4 deletions exec/ff-node-shelly-testnet-relay.v2
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ stop() {
choice() { i=$1; shift; eval "echo \${$((i + 1))}"; }

cexec() {
BASE_CONFIG="${SCRIPTDIR}/../src/tconfig/testnet-config.json"
TOPOLOGY_CONFIG="${SCRIPTDIR}/../src/tconfig/testnet-topology.json"
BASE_CONFIG="${SCRIPTDIR}/../src/tconfig/preview/config.json"
TOPOLOGY_CONFIG="${SCRIPTDIR}/../src/tconfig/preview/topology.json"
CARDANO_NODE="/home/nsaha/.cabal/bin/cardano-node"
HOST_IP="$(wget http://ipecho.net/plain -O - -q ; echo)"
PORT=3001
HOST_IP="$(curl api.ipify.org)"
PORT=6001
DB_DIR="${NODE_DIR}/db-ff"
SOCKET="${NODE_DIR}/node.socket"

Expand Down
29 changes: 29 additions & 0 deletions exec/install_local_libs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
#!/bin/sh

#install pre-req
sudo apt update
sudo apt install build-essential
sudo apt-get install libtool
sudo apt-get install autoconf

sudo apt-get install -y \
git automake build-essential pkg-config \
libffi-dev libgmp-dev libssl-dev \
libtinfo-dev libsystemd-dev \
zlib1g-dev make g++ tmux git \
jq wget libncursesw5 \
libtool autoconf curl \
awscli

git clone https://github.com/input-output-hk/libsodium; \
cd libsodium; \
git checkout 66f017f1; \
./autogen.sh; \
./configure; \
make; \
make install;

export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"

git clone https://github.com/bitcoin-core/secp256k1.git; \
cd secp256k1; \
git reset --hard ac83be33d0956faf6b7f61a60ab524ef7d6a473a ; \
Expand All @@ -8,3 +34,6 @@ git clone https://github.com/bitcoin-core/secp256k1.git; \
make; \
make check; \
sudo make install;

#cleanup
rm -rf libsodium secp256k1
8 changes: 8 additions & 0 deletions exec/start_cw_local_node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

CARDANO_WALLET="/home/nsaha/.cabal/bin/cardano-wallet"
CONFIG_FILE="$HOME/projects/cardano-scripts/src/tconfig/mainnet/byron-genesis.json"
DB_DIR="$HOME/wallets/db"
SOCKET="$HOME/projects/cardano-scripts/exec/state-node-shelly-mainnet/node.socket"

$CARDANO_WALLET serve --port 8090 --mainnet --database $DB_DIR --node-socket $SOCKET --token-metadata-server https://tokens.cardano.org --trace-wallet-db=debug
8 changes: 8 additions & 0 deletions exec/start_cw_local_node_preview.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

CARDANO_WALLET="/home/nsaha/.cabal/bin/cardano-wallet"
CONFIG_FILE="$HOME/projects/cardano-scripts/src/tconfig/preview/byron-genesis.json"
DB_DIR="$HOME/wallets/db"
SOCKET="$HOME/projects/cardano-scripts/exec/cardano-chain-data-store/node.socket"

$CARDANO_WALLET serve --port 8090 --testnet $CONFIG_FILE --database $DB_DIR --node-socket $SOCKET --token-metadata-server https://tokens.cardano.org --trace-wallet-db=debug
19 changes: 19 additions & 0 deletions exec/system_script/shelley-cardano-wallet-preview.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Unit]
Description=Shelly-testnet cardano wallet service. Relies on a relay being run locally.

[Service]
User=nsaha
Group=nsaha
TimeoutStartSec=0
Type=simple
KillMode=process
Environment=LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH":
WorkingDirectory=/home/nsaha/project/cardano-scripts/exec
ExecStart=/home/nsaha/project/cardano-scripts/exec/start_cw_local_node_preview.sh
ExecStop=/usr/bin/pkill -15 cardano-wallet

[Service]


[Install]
WantedBy=multi-user.target
19 changes: 19 additions & 0 deletions exec/system_script/shelley-cardano-wallet.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Unit]
Description=Shelly-testnet cardano wallet service. Relies on a relay being run locally.

[Service]
User=nsaha
Group=nsaha
TimeoutStartSec=0
Type=simple
KillMode=process
Environment=LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH":
WorkingDirectory=/home/nsaha/project/cardano-scripts/exec
ExecStart=/home/nsaha/project/cardano-scripts/exec/start_cw_local_node_preview.sh
ExecStop=/usr/bin/pkill -15 cardano-wallet

[Service]


[Install]
WantedBy=multi-user.target
2 changes: 2 additions & 0 deletions exec/system_script/shelly-cardano.service
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Environment=LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH":
WorkingDirectory=/home/nsaha/projects/cardano/cardano-scripts/exec
ExecStart=/home/nsaha/project/cardano/cardano-scripts/exec/ff-node-shelly-mainnet-relay.v2 start
ExecStop=/usr/bin/pkill -2 cardano-node
Restart=always
RestartSec=5s

[Service]
# Configures the time to wait before service is stopped forcefully.
Expand Down
8 changes: 8 additions & 0 deletions src/cardano-submit-api/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

SUBMIT_API="$HOME/.cabal/bin/cardano-submit-api"
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SUBMIT_API_CONFIG="${SCRIPT_DIR}/../tconfig/preview/submit-api-config.json"
CARDANO_NODE_SOCKET_PATH='/home/nsaha/projects/cardano-scripts/exec/cardano-chain-data-store/./node.socket'

${SUBMIT_API} --config $SUBMIT_API_CONFIG --shelley-mode --socket-path $CARDANO_NODE_SOCKET_PATH --testnet-magic 2 --listen-address 127.0.0.1 --port 9001
22 changes: 22 additions & 0 deletions src/cardano-submit-api/submit-api-cardano.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[Unit]
Description=cardano-submit-api

[Service]
User=nsaha
Group=nsaha
TimeoutStartSec=300
Type=simple
KillMode=process
Environment=LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH":
WorkingDirectory=/home/nsaha/projects/cardano-scripts/src/cardano-submit-api
ExecStart=/home/nsaha/projects/cardano-scripts/src/cardano-submit-api/start.sh
ExecStop=/usr/bin/pkill -2 cardano-submit-api
Restart=always
RestartSec=5s

[Service]
# Configures the time to wait before service is stopped forcefully.
TimeoutStopSec=300

[Install]
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion src/config/pool_stakeData.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"amount": 5000000000,
"cost": 340000000,
"margin": 0.99
"margin": 0.25
}
48 changes: 25 additions & 23 deletions src/create_keys_addr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,30 @@

CWD=os.getcwd()

#BASE_URL = 'https://hydra.iohk.io/job/Cardano/cardano-node/cardano-deployment/latest-finished/download/1/'
#BASE_URL = 'http://hydra.iohk.io/job/Cardano/iohk-nix/cardano-deployment/latest-finished/download/1/'
BASE_URL = 'https://hydra.iohk.io/job/Cardano/cardano-node/cardano-deployment/latest-finished/download/1/'
BASE_URL = 'https://book.world.dev.cardano.org/environments/'
CARDANO_CLI="/home/nsaha/.cabal/bin/cardano-cli"

FILES={
'configurations': {
'mainnet':{
'config':os.path.join( CWD, 'tconfig/mainnet-config.json'),
'topology':os.path.join( CWD, 'tconfig/mainnet-topology.json'),
'shelley-genesis':os.path.join( CWD, 'tconfig/mainnet-shelley-genesis.json'),
'byron-genesis':os.path.join( CWD, 'tconfig/mainnet-byron-genesis.json'),
'alonzo-genesis':os.path.join( CWD, 'tconfig/mainnet-alonzo-genesis.json'),
'config':os.path.join( CWD, 'tconfig/mainnet/config.json'),
'topology':os.path.join( CWD, 'tconfig/mainnet/topology.json'),
'shelley-genesis':os.path.join( CWD, 'tconfig/mainnet/shelley-genesis.json'),
'byron-genesis':os.path.join( CWD, 'tconfig/mainnet/byron-genesis.json'),
'alonzo-genesis':os.path.join( CWD, 'tconfig/mainnet/alonzo-genesis.json'),
'submit-api-config':os.path.join( CWD, 'tconfig/mainnet/submit-api-config.json'),
'db-sync-config':os.path.join( CWD, 'tconfig/mainnet/db-sync-config.json'),
'conway-genesis':os.path.join( CWD, 'tconfig/mainnet/conway-genesis.json'),
},
'testnet':{
'config':os.path.join( CWD, 'tconfig/testnet-config.json'),
'topology':os.path.join( CWD, 'tconfig/testnet-topology.json'),
'shelley-genesis':os.path.join( CWD, 'tconfig/testnet-shelley-genesis.json'),
'byron-genesis':os.path.join( CWD, 'tconfig/testnet-byron-genesis.json'),
'alonzo-genesis':os.path.join( CWD, 'tconfig/mainnet-alonzo-genesis.json'),
'preview':{
'config':os.path.join( CWD, 'tconfig/preview/config.json'),
'topology':os.path.join( CWD, 'tconfig/preview/topology.json'),
'shelley-genesis':os.path.join( CWD, 'tconfig/preview/shelley-genesis.json'),
'byron-genesis':os.path.join( CWD, 'tconfig/preview/byron-genesis.json'),
'alonzo-genesis':os.path.join( CWD, 'tconfig/preview/alonzo-genesis.json'),
'submit-api-config':os.path.join( CWD, 'tconfig/preview/submit-api-config.json'),
'db-sync-config':os.path.join( CWD, 'tconfig/preview/db-sync-config.json'),
'conway-genesis':os.path.join( CWD, 'tconfig/preview/conway-genesis.json'),
}
}
}
Expand Down Expand Up @@ -59,20 +63,18 @@ def fetch_init_files(network='mainnet'):
"""
print(f"fetch_init_files")
try:
fnames = [f'{network}-config.json', f'{network}-topology.json', f'{network}-shelley-genesis.json',f'{network}-byron-genesis.json',f'{network}-alonzo-genesis.json' ]
fnames = [f'{network}/config.json', f'{network}/topology.json', f'{network}/shelley-genesis.json',f'{network}/byron-genesis.json',f'{network}/alonzo-genesis.json', f'{network}/conway-genesis.json', f'{network}/db-sync-config.json', f'{network}/submit-api-config.json' ]

for c in fnames:
turl = BASE_URL+c
r1 = requests.get(url = BASE_URL+c)
print(f"fetched content url:{turl}")

r1 = requests.get(url = BASE_URL+c)
print(f"content is {r1.text}")
t = c.split('candidate_3')[-1].split('-')
t = c.split('/')
t.pop(0)
print(f"value of t:{t}")
if len(t) > 1:
key = "-".join(t).split('.')[0]
else:
key=t[0].split('.')[0]
if len(t) >= 1:
key = t[0].split(".")[0]
print(f"key is {key}")
destination = FILES['configurations'][network][key]
print(f"destination is: {destination}")
Expand Down Expand Up @@ -182,7 +184,7 @@ def main(self):
Options to download config files or to create keys etc.
"""
parser = argparse.ArgumentParser(description=descr, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("--network", help="The network should be either 'mainnet' or 'testnet'", default="mainnet")
parser.add_argument("--network", help="The network should be either 'mainnet' or 'preview' or 'preprod'", default="mainnet")
parser.add_argument("--configs", help="Fetch the configs and store them in proper directory",action="store_true")
parser.add_argument("--kaddr", help="create the pairs of keys corresponding to the github.com/input-output-hk/cardano-tutorials/blob/master/node-setup/020_keys_and_addresses.md",action="store_true")
args = parser.parse_args()
Expand Down
11 changes: 5 additions & 6 deletions src/cscripts/download_and_install_binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BASE_BINARY_DIR="$HOME/.cabal/bin"
./download_binaries.sh $VERSION_ID

#Now backup the current .cabal directory
DATE=$(date +%d/%m/%y)
DATE=$(date %s)
BACKUP_BIN_DIR="$HOME/.cabal/bin_$DATE"


Expand All @@ -28,16 +28,15 @@ fi
mv $BASE_BINARY_DIR/* $BACKUP_BIN_DIR/.

#And move the latest binary
mv $STORAGE_DIR/* $BASE_BINARY_DIR/.
for i in `ls $BASE_BINARY_DIR`
for i in `find ${STORAGE_DIR} -executable`
do
chmod +x $BASE_BINARY_DIR/$i
cp $i $BASE_BINARY_DIR/.
done


#Now restart the blockchain
#sudo systemctl stop shelly-cardano
kill -2 `pgrep -u nsaha cardano-node`
kill -15 `pgrep -u nsaha cardano-node`
sudo systemctl daemon-reload
sleep 60s
sudo systemctl start shelly-cardano
Expand Down
11 changes: 8 additions & 3 deletions src/cscripts/download_binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ if [ ! -d "$STORAGE_DIR" ]; then
mkdir -p $STORAGE_DIR
fi

aws s3 cp s3://stake-pool/cardano-cli-${VERSION_ID} $STORAGE_DIR/cardano-cli
aws s3 cp s3://stake-pool/cardano-node-${VERSION_ID} $STORAGE_DIR/cardano-node
aws s3 cp s3://stake-pool/cardano-node-chairman-${VERSION_ID} $STORAGE_DIR/cardano-node-chairman
cd $STORAGE_DIR
BINARY_FILENAME=cardano-node-${VERSION_ID}-linux.tar.gz
wget https://github.com/input-output-hk/cardano-node/releases/download/${VERSION_ID}/${BINARY_FILENAME}
tar xvfz $BINARY_FILENAME

# aws s3 cp s3://stake-pool/cardano-cli-${VERSION_ID} $STORAGE_DIR/cardano-cli
# aws s3 cp s3://stake-pool/cardano-node-${VERSION_ID} $STORAGE_DIR/cardano-node
# aws s3 cp s3://stake-pool/cardano-node-chairman-${VERSION_ID} $STORAGE_DIR/cardano-node-chairman
Loading

0 comments on commit 445c8f0

Please sign in to comment.