-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently working only the init command
- Loading branch information
Showing
5 changed files
with
253 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
echo | ||
echo "This container runs a node based on Mokamint." | ||
echo "It understands the following commands and options" | ||
echo "(use \"-e option=value\" to set options in docker):" | ||
echo | ||
echo " help: prints this help" | ||
echo | ||
echo " init: creates a node for a brand new blockchain" | ||
echo " CHAIN_ID: the chain identifier of the new blockchain" | ||
echo " [default: the string \"missing\"]" | ||
echo " DELTA_SUPPLY: the number of coins that can be minted during the life of the node," | ||
echo " as effect of inflation" | ||
echo " [default: equal to INITIAL_SUPPLY, hence the supply can double at most]" | ||
echo " KEY_OF_GAMETE: the Base58-encoded ed25519 public key of the gamete." | ||
echo " Use \"moka create-key\" to generate one" | ||
echo " [required, no default]" | ||
echo " INFLATION: the inflation added to the validators' reward at each commit:" | ||
echo " 0 means 0%, 1000000 means 1% (this can be negative)." | ||
echo " Use 0 to keep the total supply constant" | ||
echo " [default: 100000]" | ||
echo " INITIAL_GAS_PRICE: the initial price of a unit of gas" | ||
echo " [default: 100]" | ||
echo " INITIAL_SUPPLY: the initial balance of the node," | ||
echo " which goes to the gamete" | ||
echo " [default: 100000000000000000000000000000]" | ||
echo " MAX_GAS_PER_VIEW: the maximal gas limit allowed when running @View methods" | ||
echo " [default: 10000000]" | ||
echo " OBLIVION: a measure of how quickly the gas consumed by previous blocks" | ||
echo " is forgotten for the computation of the gas price:" | ||
echo " 0 means never (ie, the gas price is constant), 1000000 means immediately." | ||
echo " Higher values make the gas price fluctuate more heavily" | ||
echo " [default: 250000]" | ||
echo " OPEN_UNSIGNED_FAUCET: true if the gamete can be used as a free faucet of coins" | ||
echo " [default: false]" | ||
echo | ||
echo " start: creates a node that connects to an already existing node of a blockchain" | ||
echo " MAX_GAS_PER_VIEW: the maximal gas limit allowed when running @View methods" | ||
echo " [default: 10000000]" | ||
echo " NETWORK_URI: the URI of the already existing node" | ||
echo " [default: ws://panarea.hotmoka.io]" | ||
echo " TIMEOUT_COMMIT: commit timeout in seconds, which determines the block creation time" | ||
echo " [default: 5]" | ||
echo " PUBLIC_KEY_BASE58: the base58-encoded public key of the node if it becomes a validator" | ||
echo " [default: a new automatically-generated public key]" | ||
echo " PUBLIC_KEY_BASE64: the base64-encoded public key of the node if it becomes a validator" | ||
echo " [default: a new automatically-generated private key]" | ||
echo " CONCATENATED_KEYS_BASE64: the base64-encoded concatenation of the private and public keys" | ||
echo " of the node if it becomes a validator" | ||
echo " [default: a new automatically-generated concatenation key]" | ||
echo " TENDERMINT_ADDRESS: the Tendermint address of the node if it becomes a validator" | ||
echo " [default: a new automatically-generated Tendermint address]" | ||
echo | ||
echo " resume: resumes a node whose container was previously turned off with \"docker stop\"" | ||
echo " MAX_GAS_PER_VIEW: the maximal gas limit allowed when running @View methods" | ||
echo " [default: 10000000]" | ||
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
INITIAL_SUPPLY=${INITIAL_SUPPLY:-100000000000000000000000000000} | ||
DELTA_SUPPLY=${DELTA_SUPPLY:-${INITIAL_SUPPLY}} | ||
OPEN_UNSIGNED_FAUCET=${OPEN_UNSIGNED_FAUCET:-false} | ||
KEY_OF_GAMETE=${KEY_OF_GAMETE:-missing} | ||
CHAIN_ID=${CHAIN_ID:-missing} | ||
MAX_GAS_PER_VIEW=${MAX_GAS_PER_VIEW:-10000000} | ||
OBLIVION=${OBLIVION:-250000} | ||
INFLATION=${INFLATION:-100000} | ||
INITIAL_GAS_PRICE=${INITIAL_GAS_PRICE:-100} | ||
|
||
echo | ||
echo "Starting a Mokamint node as the single initial node of a brand new blockchain" | ||
echo " CHAIN_ID=$CHAIN_ID" | ||
echo " INITIAL_SUPPLY=$INITIAL_SUPPLY" | ||
echo " DELTA_SUPPLY=$DELTA_SUPPLY" | ||
echo " KEY_OF_GAMETE=$KEY_OF_GAMETE" | ||
echo " INITIAL_GAS_PRICE=$INITIAL_GAS_PRICE" | ||
echo " OPEN_UNSIGNED_FAUCET=$OPEN_UNSIGNED_FAUCET" | ||
echo " MAX_GAS_PER_VIEW=$MAX_GAS_PER_VIEW" | ||
echo " OBLIVION=$OBLIVION" | ||
echo " INFLATION=$INFLATION" | ||
|
||
# set the chain id as requested | ||
sed -i "s/chain_id = .*/chain_id = \"$CHAIN_ID\"/" mokamint_config.cfg | ||
|
||
# invoke moka in a way that uses the mokamint configuration that was previously created inside the chain directory | ||
moka init-mokamint ${INITIAL_SUPPLY} --delta-supply=${DELTA_SUPPLY} --interactive=true --open-unsigned-faucet=${OPEN_UNSIGNED_FAUCET} --key-of-gamete=${KEY_OF_GAMETE} --takamaka-code /modules/explicit/io-takamaka-code-TAKAMAKA-VERSION.jar --mokamint-config=mokamint_config.cfg --plot mokamint_node/plot.plot --keys mokamint_node/node.pem --keys-of-plot mokamint_node/miner.pem --max-gas-per-view ${MAX_GAS_PER_VIEW} --oblivion ${OBLIVION} --inflation ${INFLATION} --initial-gas-price ${INITIAL_GAS_PRICE} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# In order to create the image: | ||
# | ||
# docker buildx build --platform linux/amd64 -t hotmoka/mokamint-node:latest -f dockerfiles/mokamint-node/mokamint-node . | ||
# | ||
# In order to publish a node at port 8001 whose underlying Mokamint node is published at port 8030: | ||
# create a local directory "mokamint_node" containing three files, named exactly as follows: | ||
# | ||
# miner.pem | ||
# node.pem | ||
# plot.plot | ||
# | ||
# Then run: | ||
# | ||
# docker run -it --name mokamint_node -e KEY_OF_GAMETE=BFtoCuWq962dRyW5Mq311Na7qQmXjhH9gk4kp1AfAxMz -e CHAIN_ID=caatinga -p 8001:8001 -p 8030:8030 -v chain:/home/hotmoka/chain -v ./mokamint_node:/home/hotmoka/mokamint_node hotmoka/mokamint-node:latest init | ||
# | ||
# (assuming that the public Base58 key of the gamete will be BFtoCuWq962dRyW5Mq311Na7qQmXjhH9gk4kp1AfAxMz and that the chain identifier will be caatinga; this chain identifier | ||
# must coincide with that used in plot.plot; similarly, plot.plot must use node.pem as key for signing the blocks and miner.pem as key for signing the deadlines) | ||
# | ||
# When the docker container has initialized the node, you can detach from it with CTRL+P CTRL+Q | ||
# | ||
# Later you can stop the container with: | ||
# docker stop mokamint_node | ||
|
||
FROM openjdk:19-jdk-slim | ||
LABEL "maintainer"="[email protected]" | ||
|
||
USER root | ||
WORKDIR /usr/local/bin | ||
|
||
# install missing packages | ||
RUN apt-get update \ | ||
&& apt-get install -y python3 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# create hotmoka user | ||
RUN groupadd -r hotmoka \ | ||
&& useradd --no-log-init -r -m -g hotmoka hotmoka | ||
|
||
# create a volume for the chain of this container and make it writable to everyone | ||
RUN mkdir /home/hotmoka/chain \ | ||
&& chmod -R a+w /home/hotmoka/chain | ||
|
||
# install moka and its alias moka-no-logs that does not report logs | ||
COPY io-hotmoka-moka/modules/ /modules/ | ||
# we add /home/hotmoka to the classpath in order to find the logging properties file | ||
RUN echo java -Djava.util.logging.config.file=logging.properties --module-path /modules/explicit:/modules/automatic --class-path \"/home/hotmoka/:/modules/unnamed/*\" --add-modules org.glassfish.tyrus.container.grizzly.server,org.glassfish.tyrus.container.grizzly.client --module io.hotmoka.moka/io.hotmoka.moka.Moka \"\$@\" > moka \ | ||
&& chmod a+x moka \ | ||
&& echo java --module-path /modules/explicit:/modules/automatic --class-path \"/home/hotmoka/:/modules/unnamed/*\" --add-modules org.glassfish.tyrus.container.grizzly.server,org.glassfish.tyrus.container.grizzly.client --module io.hotmoka.moka/io.hotmoka.moka.Moka \"\$@\" > moka-no-logs \ | ||
&& chmod a+x moka-no-logs | ||
|
||
# install the control scripts | ||
COPY dockerfiles/mokamint-node/help help | ||
COPY dockerfiles/mokamint-node/init init | ||
#COPY dockerfiles/mokamint-node/resume resume | ||
#COPY dockerfiles/mokamint-node/start start | ||
RUN chmod 755 help && chmod 755 init #&& chmod 755 resume && chmod 755 start | ||
|
||
USER hotmoka | ||
WORKDIR /home/hotmoka | ||
|
||
# install the logging configuration | ||
COPY --chown=hotmoka dockerfiles/logging.properties logging.properties | ||
|
||
# install the default Mokamint configuration | ||
COPY --chown=hotmoka io-hotmoka-moka/mokamint_configs/default.cfg mokamint_config.cfg | ||
|
||
# by default, print a help message | ||
CMD help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# This is a TOML config file for Mokamint nodes. | ||
# For more information about TOML, see https://github.com/toml-lang/toml | ||
# For more information about Mokamint, see https://www.mokamint.io | ||
|
||
## Consensus parameters | ||
|
||
# the chain identifier of the blockchain | ||
chain_id = "" | ||
|
||
# the hashing algorithm used for the deadlines and hence for the plot files of the miners | ||
hashing_for_deadlines = "shabal256" | ||
|
||
# the hashing algorithm used for the computation of the new generation and scoop number from the previous block | ||
hashing_for_generations = "sha256" | ||
|
||
# the hashing algorithm used for the blocks of the blockchain | ||
hashing_for_blocks = "sha256" | ||
|
||
# the hashing algorithm used for the transactions of the blockchain | ||
hashing_for_transactions = "sha256" | ||
|
||
# the signature algorithm that nodes use to sign the blocks | ||
signature_for_blocks = "ed25519" | ||
|
||
# the signature algorithm that miners use to sign the deadlines | ||
signature_for_deadlines = "ed25519" | ||
|
||
# the initial acceleration of the blockchain, at the genesis block; | ||
# this might be increased if the network starts with very little mining power | ||
initial_acceleration = 50000000000000 | ||
|
||
# time, in milliseconds, aimed between the creation of a block and the creation of a next block | ||
target_block_creation_time = 15000 | ||
|
||
# the maximal size, in bytes, of a block's transactions table | ||
max_block_size = 1000000 | ||
|
||
## Local parameters | ||
|
||
# the path where the node's data will be persisted | ||
dir = "mokamint" | ||
|
||
# maximal milliseconds to wait between deadline request to the miners and first deadline reception | ||
deadline_wait_timeout = 20000 | ||
|
||
# the initial points of a miner, freshly connected to a node | ||
miner_initial_points = 1000 | ||
|
||
# the points that a miner loses as punishment for a timeout at a request for a deadline | ||
miner_punishment_for_timeout = 1 | ||
|
||
# the points that a miner loses as punishment for providing an illegal deadline | ||
miner_punishment_for_illegal_deadline = 500 | ||
|
||
# the URIs of the initial peers, that will always get added to the previous set of peers | ||
# (if any) and contacted at start-up | ||
seeds = [] | ||
|
||
# the maximum amount of peers of a node; their actual number can be larger | ||
# only if peers are explicitly added as seeds or through the addPeer() method | ||
# of the restricted API of the node | ||
max_peers = 20 | ||
|
||
# the initial points of a peer, freshly added to a node | ||
peer_initial_points = 1000 | ||
|
||
# the maximal time difference (in milliseconds) between a node and each of its peers | ||
peer_max_time_difference = 15000 | ||
|
||
# the points that a peer loses as punishment for not answering a ping | ||
peer_punishment_for_unreachable = 1 | ||
|
||
# the time (in milliseconds) for communications to the peers | ||
peer_timeout = 10000 | ||
|
||
# the time, in milliseconds, between successive pings to a peer | ||
peer_ping_interval = 120000 | ||
|
||
# the time, in milliseconds, between successive broadcasts of a service | ||
service_broadcast_interval = 240000 | ||
|
||
# the size of the memory used to avoid whispering the same message again | ||
whispering_memory_size = 1000 | ||
|
||
# the size of the memory used to hold orphan nodes | ||
orphans_memory_size = 1000 | ||
|
||
# the size of the memory used to hold incoming transactions before they get put into blocks | ||
mempool_size = 100000 | ||
|
||
# the maximal creation time in the future (in milliseconds) of a block | ||
block_max_time_in_the_future = 2000 | ||
|
||
# the maximal time (in milliseconds) that history can be changed before being considered as definitely frozen; | ||
# a negative value means that the history is always allowed to be changed, without limits | ||
maximal_history_change_time = 300000 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters