Skip to content

Commit

Permalink
Updates:
Browse files Browse the repository at this point in the history
- Support for hostname for relay
- Fixed automatic leaderlogs submit
- Fixed slow registration of pool certificates
  • Loading branch information
Daniel committed May 30, 2022
1 parent cf68a27 commit 427e01d
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 25 deletions.
1 change: 1 addition & 0 deletions Dockerfile.pool
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ ENV NODE_PORT="3000" \
AUTO_TOPOLOGY="True" \
METADATA_URL="" \
PUBLIC_RELAY_IP="TOPOLOGY" \
PUBLIC_RELAY_HOST="" \
WAIT_FOR_SYNC="True" \
PATH="/root/.local/bin/:/scripts/:/scripts/functions/:/cardano-node/scripts/:${PATH}" \
LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}" \
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ You can pass the following environment variables to the container.
| Variable | Function |
| :-- | -- |
| NODE_PORT | Port of node. Default: 3000. |
| NODE_NAME | Name/Ticker of node. Default: node1. |
| NODE_NAME | Name of node. Default: node1. |
| NODE_TOPOLOGY | Topology of the node. Should be comma separated for each individual node to add, on the form: \<ip\>:\<port\>/\<valency\>. So for example: 127.0.0.1:3001/1,127.0.0.1:3002/1. |
| NODE_RELAY | Set to True if default IOHK relay should be added to the network topology. Default: False. |
| HOST_ADDR | Set cardano-node host address. Defaults to public IP address. |
Expand All @@ -217,6 +217,7 @@ You can pass the following environment variables to the container.
| POOL_MARGIN | Operator margin. Default: 0.05 |
| METADATA_URL | URL for file containing stake pool metadata information. See \`examples/metadata.json\` for examle. The file be uploaded to an URL accessible to public. |
| MULTI_OWNERS | Define multiple stakepool owner wallets which participates in the stakepool pledge. Comma separated values. Example: owner2,owner3. If the wallets do not exist they will automatically be created. Default: None. |
| PUBLIC_RELAY_HOST | Hostname of Relay node. Will override PUBLIC_RELAY_IP when generating certificates and submitting topology. |
| PUBLIC_RELAY_IP | Public IP address of Relay node. <br/><br/>Values:<br/>\<Any IP address\><br/>TOPOLOGY: Use first entry of the topology.<br/>PUBLIC: Use public IP of node.<br/>Default: TOPOLOGY. |
| PUBLIC_RELAY_PORT | Public port of Relay node. <br/><br/>Values:<br/>\<Any Port\><br/>If PUBLIC_RELAY_IP=TOPOLOGY the PUBLIC_RELAY_PORT will also be updated accordingly.<br/>Default: First entry of the topology. |
| AUTO_TOPOLOGY | Automatically update topology.json. Default: True |
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LIBSODIUM_VERSION="66f017f1"
ADDRESS_VERSION="3.8.0"
BECH_VERSION="1.1.2"
CNCLI_VERSION="4.0.4"
POOL_VERSION="1.34.1-2"
POOL_VERSION="1.34.1-4"

docker build -f Dockerfile.node \
--build-arg VERSION=${NODE_VERSION} \
Expand Down
3 changes: 2 additions & 1 deletion scripts/functions/run_stakingnode
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ function run_stakingnode {

if [[ "$PT_SENDSLOTS"="True" ]]; then
# Add to crontab
echo "00 22 * * * send_slots" >> /crontab
echo "0 21 * * * every_five_days && leaderlogs_cncli next" >> /crontab
echo "55 21 * * * every_five_days && send_slots" >> /crontab
crontab /crontab
fi
fi
Expand Down
9 changes: 9 additions & 0 deletions scripts/generate_registration_certificates
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,19 @@ if [ ! -f "pool.cert" ] || [ -n "$UPDATE_CERT" ]; then
PUBLIC_RELAY_PORT=$(jq -r ".Producers[0].port" ${NODE_PATH}/topology.json)
fi

if [ -n "$PUBLIC_RELAY_HOST" ]; then
POOL_RELAY="--pool-relay-host ${PUBLIC_RELAY_HOST}"
else
POOL_RELAY="--pool-relay-ipv4 ${PUBLIC_RELAY_IP}"
fi


echo "Generating pool.cert"
stakepool_info
echo "Public Relay IP: ${PUBLIC_RELAY_IP}"
echo "Public Relay Host: ${PUBLIC_RELAY_HOST}"
echo "Public Relay Port: ${PUBLIC_RELAY_PORT}"
echo "POOL_RELAY: ${POOL_RELAY}"

# Multiple owners
if [ -n "$MULTI_OWNERS" ]; then
Expand Down
32 changes: 32 additions & 0 deletions scripts/leaderlogs_cncli
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

source /scripts/init_node_vars

# Init vars
POOL_ID=$(cat ${NODE_PATH}/staking/POOL_ID)
BYRON_GENESIS=${NODE_PATH}/byron-genesis.json
SHELLEY_GENESIS=${NODE_PATH}/shelley-genesis.json
VRF=${NODE_PATH}/staking/pool-keys/vrf.skey
SNAPSHOT=/tmp/stake-snapshot.json
LSET="${1:-current}"

case ${LSET} in
prev|current|next) echo "Running leaderlogs for ${LSET} epoch" ;;
*) echo "Invalid argument. Must be either prev|current|next"; exit ;;
esac

echo "Generating snapshot"
cardano-cli query stake-snapshot --stake-pool-id ${POOL_ID} ${NETWORK_ARGUMENT} > ${SNAPSHOT}
ACTIVE_STAKE=$(cat $SNAPSHOT | jq .activeStakeSet)
POOL_STAKE=$(cat $SNAPSHOT | jq .poolStakeSet)

# Get leaderlogs
echo "Running leaderlogs"
cncli leaderlog --db ${NODE_PATH}/cncli.db \
--pool-id ${POOL_ID} \
--pool-vrf-skey ${VRF} \
--byron-genesis ${BYRON_GENESIS} \
--shelley-genesis ${SHELLEY_GENESIS} \
--active-stake ${ACTIVE_STAKE} \
--pool-stake ${POOL_STAKE} \
--ledger-set ${LSET} | tee ${NODE_PATH}/leaderlog_cncli.json
19 changes: 2 additions & 17 deletions scripts/register_stake_pool
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,7 @@ case $i in
esac
done

EXTRA_FEE=9000

if [ -z "$COLD_CREATE" ]; then
if [ -z "$UPDATE" ]; then
if [ -n "$(check_pool_registration)" ]; then
echo "Your stake pool has already been registered in the blockchain."
touch ${NODE_PATH}/staking/wallets/owner/transactions/register_stake_pool.submitted
exit
fi
else
if [ -z "$(check_pool_registration)" ]; then
echo "Pool is not registered in the blockchain. You cannot update the certificates. Register the stakepool first."
exit
fi
fi
fi
EXTRA_FEE=15000

# Wait for node to sync
if [[ "${WAIT_FOR_SYNC}" == "True" ]]; then
Expand Down Expand Up @@ -217,7 +202,7 @@ if [ -z "$COLD_CREATE" ]; then

# Wait for blockchain to register the pool
#wait_for_slot ${TTL}
wait_for_pool_registration
#wait_for_pool_registration
echo "Your stake pool registration has been sent to the blockchain."
touch ${NODE_PATH}/staking/wallets/owner/transactions/register_stake_pool.submitted
fi
Expand Down
8 changes: 4 additions & 4 deletions scripts/send_slots
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash

source /scripts/init_node_vars

POOL_ID=$(cat ${NODE_PATH}/staking/POOL_ID)
VRF=${NODE_PATH}/staking/pool-keys/vrf.skey
BYRON_GENESIS=${NODE_PATH}/byron-genesis.json
SHELLEY_GENESIS=${NODE_PATH}/shelley-genesis.json
SNAPSHOT=/tmp/stake-snapshot.json

every_five_days \
&& cardano-cli query ledger-state --mary-era ${NETWORK_ARGUMENT} > /tmp/ledger-state-mainnet.json \
&& cncli leaderlog --pool-id ${POOL_ID} --pool-vrf-skey ${VRF} --byron-genesis ${BYRON_GENESIS} --shelley-genesis ${SHELLEY_GENESIS} --ledger-state /tmp/ledger-state-mainnet.json --ledger-set next | tee ${NODE_PATH}/leaderlog.json \
&& cncli sendslots --byron-genesis ${BYRON_GENESIS} --shelley-genesis ${SHELLEY_GENESIS} --config ${NODE_PATH}/pooltool.json
cncli sendslots --db ${NODE_PATH}/cncli.db --byron-genesis ${BYRON_GENESIS} --shelley-genesis ${SHELLEY_GENESIS} --config ${NODE_PATH}/pooltool.json
7 changes: 6 additions & 1 deletion scripts/topology_submit
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ mkdir -p ${NODE_PATH}/logs/

NWMAGIC=$(jq -r .networkMagic < ${NODE_PATH}/shelley-genesis.json)
BLOCK=$(get_block)
PUBLIC_IP=$(get_public_ip)

if [ -n "$PUBLIC_RELAY_HOST" ]; then
PUBLIC_IP=${PUBLIC_RELAY_HOST}
else
PUBLIC_IP=$(get_public_ip)
fi

echo "Submitting node IP to api.clio.one" | tee -a $LOG_FILE

Expand Down

0 comments on commit 427e01d

Please sign in to comment.