Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Juicy fixes #144

Merged
merged 4 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
behave.ini
Dockerfile
README.md
e2e
target/classes
target/global-logging
target/src_managed
Expand Down
43 changes: 36 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ sbt build

It will produce `lto-public-all-*.jar` in the `target` folder.

To package the build as debian package, run
```
sbt packageAll -Dnetwork=mainnet # Mainnet
sbt packageAll -Dnetwork=testnet -DpackageName=lto-testnet # Testnet
```

For further information please read the [LTO Network documentation](https://docs.ltonetwork.com).

# Docker
Expand Down Expand Up @@ -61,7 +55,42 @@ docker run -p 6869:6869 -p 6863:6863 -e LTO_NETWORK=TESTNET -e LTO_HEAP_SIZE=2g
| `LTO_ENABLE_MINING` | To enable PoS mining (default is `true`) |
| `LTO_FEATURES` | Features you wish to vote. E.g. set to 4 to start voting for the Smart Accounts feature. You can also vote for multiple features at by comma seperating them (e.g. 4,5) |

**Note: All variables are optional.**
_Note: All variables are optional._

**The following variables can be used to control fee voting:**

| Env variable | Description |
|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `COINMARKETCAP_API_KEY` | [CoinMarketCap API key](https://pro.coinmarketcap.com/). When supplied, the script will query CoinMarketCap in addition to CoinGecko to prevent voting based on incorrect data. |
| `LTO_FEE_TARGET` | Value to determine how to vote. See [Fee Prices](https://blog.ltonetwork.com/tokenomics-update/#fee-prices). |

# Debian

To package the build as debian package, run
```
sbt packageAll -Dnetwork=mainnet # Mainnet
sbt packageAll -Dnetwork=testnet -DpackageName=lto-testnet # Testnet
```

## Installation

The `.deb` package can be downloaded from the [GitHub release page](https://github.com/ltonetwork/lto-public-chain/releases).

wget https://github.com/ltonetwork/lto-public-chain/releases/download/v1.6.2/lto_1.6.2_all.deb
dpkg -i lto_1.6.2_all.deb

## Fee vote

The debian package installs a python script named `lto-fee-vote`. Please participate in
[Fee voting](https://blog.ltonetwork.com/tokenomics-update/#fee-voting) by calling this script through a cronjob once an
hour.

0 * * * * root /usr/bin/lto-fee-vote http://localhost:6869 /var/lib/lto/lto/fee-vote

_For testnet use the path `/var/lib/lto-testnet/lto/fee-vote` instead._

If you choose not to enable the REST API on your node, you can query `https://nodes.lto.network` instead of
`http://localhost:6869`.

# Tests

Expand Down
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ inConfig(Universal)(
case other => other
}
},
mappings += (baseDirectory.value / s"fee-vote.py" -> "bin/lto-fee-vote"),
javaOptions ++= Seq(
// -J prefix is required by the bash script
"-J-server",
Expand Down
2 changes: 0 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@

/usr/bin/python3 "/lto-node/starter.py"

echo $LTO_CONFIG_FILE

echo "Node is starting..."
${JAVA_HOME}/bin/java -Dlogback.stdout.level="${LTO_LOG_LEVEL}" "-Xmx${LTO_HEAP_SIZE}" -jar "/lto-node/lto-public-all.jar" $LTO_CONFIG_FILE
7 changes: 7 additions & 0 deletions fee-vote.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

# Vote to increase, maintain, or decrease the fee, based on the current price of LTO in USD.
# This script should be run a cron job once an hour.

Expand Down Expand Up @@ -76,6 +78,11 @@ def main(node: str, file: str):


if __name__ == '__main__':
if (len(sys.argv) < 3):
print("USAGE: fee-vote NODE_URL PATH")
sys.exit(1)


try:
main(sys.argv[1], sys.argv[2])
sys.exit(0)
Expand Down
1 change: 0 additions & 1 deletion hooks/post_push
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ docker push $DOCKER_REPO:$MINOR_VERSION

docker tag $IMAGE_NAME $DOCKER_REPO:edge
docker push $DOCKER_REPO:edge

Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ object FunctionalitySettings {
doubleFeaturesPeriodsAfterHeight = -1,
feeVoteBlocksPeriod = 1000,
blocksForFeeChange = 600,
miningReward = 10L * 10^8,
miningReward = 1000000000L,
miningRewardBonus = 1000L,
miningRewardBonusPeriod = 2500000,
leaseUnbondingPeriod = 3000,
Expand All @@ -63,7 +63,7 @@ object FunctionalitySettings {
doubleFeaturesPeriodsAfterHeight = -1,
feeVoteBlocksPeriod = 1000,
blocksForFeeChange = 600,
miningReward = 10L * 10^8,
miningReward = 1000000000L,
miningRewardBonus = 1000L,
miningRewardBonusPeriod = 2500000,
leaseUnbondingPeriod = 1000,
Expand Down
4 changes: 4 additions & 0 deletions src/package/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ if [ "$1" = configure ]; then
fi
fi

if [ -f "/usr/share/${{app_name}}/bin/lto-fee-vote" ]; then
chmod ug+x /usr/share/${{app_name}}/bin/lto-fee-vote
fi

exit 0
67 changes: 5 additions & 62 deletions src/package/debian/preinst
Original file line number Diff line number Diff line change
@@ -1,67 +1,10 @@
${{header}}
${{loader-functions}}

if [ "$1" = upgrade ]; then
if dpkg --compare-versions "$2" lt 0.7.5 ; then
# change home directory and remove legacy data files
rm -f /home/${{app_name}}/lto/data/blockchain.dat
rm -f /home/${{app_name}}/lto/data/peers.dat

# delete legacy configuration files
for file_to_remove in application.conf application-dev.conf logback-to-file.xml logback.xml logback-overrides.xml
do
rm -f /usr/share/${{app_name}}/conf/$file_to_remove
done

rm -fr /usr/share/${{app_name}}/conf/target

chmod -s -x /usr/share/${{app_name}}/conf/* || true

# move wallet file to a new default location
if [ -f /home/${{app_name}}/lto/wallet/wallet.s.dat ]; then
echo Moving wallet file to a new default location ...
mkdir -p /var/lib/${{app_name}}/wallet/
mv /home/${{app_name}}/lto/wallet/wallet.s.dat /var/lib/${{app_name}}/wallet/wallet.dat
fi

if [ -f /etc/${{app_name}}.conf ]; then
echo Moving node configuration file from /etc/${{app_name}}.conf to /etc/${{app_name}}/lto.conf ...
mv /etc/${{app_name}}.conf /etc/${{app_name}}/lto.conf || true
fi

# if config file has not been manually altered, just remove lto.directory and wallet.file keys
sed -i.bak '/directory\s*=\s*"\?\/home\/lto\/lto"\?\|file\s*=\s*"\?\/home\/lto\/lto\/wallet\/wallet\.s\.dat/d' /etc/${{app_name}}/lto.conf

if [ -d /home/${{app_name}}/lto/data ]; then
echo Moving data files ...

mv /home/${{app_name}}/lto/data /var/lib/${{app_name}}/data || true
mv /home/${{app_name}}/lto/journal /var/lib/${{app_name}}/journal || true
mv /home/${{app_name}}/lto/snapshots /var/lib/${{app_name}}/snapshots || true
fi

if [ -f /etc/${{app_name}}.json ]; then
echo Moving legacy configuration file to a new location ...
cp /etc/${{app_name}}.json /etc/${{app_name}}/lto.json
chmod -x /etc/${{app_name}}/lto.json
fi

rm -f /etc/${{app_name}}.json
rm -f /usr/share/${{app_name}}/settings.json
fi

if dpkg --compare-versions "$2" le 0.8.7 && [ -f /etc/${{app_name}}/lto.conf ] ; then
echo Backing up local configuration file ...
mv /etc/${{app_name}}/lto.conf /etc/${{app_name}}/lto.conf.bak
fi

if dpkg --compare-versions "$2" lt 0.8.11 ; then
rm -f /etc/${{app_name}}/upstart.conf
if [ -L /etc/init/${{app_name}}.conf ] ; then
rm -f /etc/init/${{app_name}}.conf
fi
chmod -x /etc/${{app_name}}/application.ini
fi
fi
# if [ "$1" = upgrade ]; then
# if dpkg --compare-versions "$2" lt 1.0.0 ; then
# ...
# fi
# fi

exit 0
5 changes: 2 additions & 3 deletions starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ def create_fee_vote_cron():
return

with open('/etc/cron.d/fee-vote', 'w') as f:
f.write('0 * * * * python /lto-node/fee-vote.py %s %s\n' % (node, '/lto/fee-vote'))

f.write('* * * * * root /usr/bin/python3 /lto-node/fee-vote.py %s %s\n' % (node, '/lto/fee-vote'))
os.chmod('/etc/cron.d/fee-vote', 0o644)
os.system('crontab /etc/cron.d/fee-vote')
os.system('service cron start')


if __name__ == "__main__":
Expand Down