Skip to content

Gnosiskeyper docker dev #567

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

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
COMPOSE_PROJECT_NAME=snapshutter
# This is the default key for `geth --dev`
DEPLOY_KEY=0x44ea0c624dbec53682a11482f732dcd4e8581ed181fbfe2ad69e88523dc0a312
70 changes: 32 additions & 38 deletions docker/02-init-chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,71 +4,65 @@ source ./common.sh

$DC stop geth
$DC rm -f geth
$DC stop chain-{0..3}-{validator,sentry} chain-seed
$DC rm -f chain-{0..3}-{validator,sentry} chain-seed
$DC stop chain-{0..3}-validator chain-seed
$DC rm -f chain-{0..3}-validator chain-seed

${BB} rm -rf data/geth
${BB} rm -rf data/chain-{0..3}-{validator,sentry} data/chain-seed
${BB} mkdir -p data/chain-{0..3}-{validator,sentry}/config data/chain-seed/config
${BB} chmod -R a+rwX data/chain-{0..3}-{validator,sentry}/config data/chain-seed/config
${BB} rm -rf data/chain-{0..3}-validator data/chain-seed
${BB} mkdir -p data/chain-{0..3}-validator/config data/chain-seed/config
${BB} chmod -R a+rwX data/chain-{0..3}-validator/config data/chain-seed/config
${BB} rm -rf data/deployments

# has geth as dependency
$DC up -d geth
sleep 5
sh tools.sh
$DC up deploy-contracts

bash get-contracts.sh
# setup chain-seed
$DC run --rm --no-deps chain-seed init \
--root /chain \
--blocktime 1 \
--listen-address tcp://127.0.0.1:${TM_RPC_PORT} \
--listen-address tcp://0.0.0.0:${TM_RPC_PORT} \
--role seed

for num in 0 1 2 3; do
validator_cmd=chain-$num-validator
sentry_cmd=chain-$num-sentry
seed_node=$(cat data/chain-seed/config/node_key.json.id)@chain-seed:${TM_P2P_PORT}

$DC run --rm --no-deps ${sentry_cmd} init \
--root /chain \
--blocktime 1 \
--listen-address tcp://0.0.0.0:${TM_RPC_PORT} \
--role sentry
${BB} sed -i "/^moniker/c\moniker = \"chain-seed\"" data/chain-seed/config/config.toml

# configure validators and keypers 0-3
for num in {0..3}; do
validator_cmd=chain-$num-validator

# TODO: check if validator can have listen-address tcp://127.0.0.1...
$DC run --rm --no-deps ${validator_cmd} init \
--root /chain \
--genesis-keyper 0x440Dc6F164e9241F04d282215ceF2780cd0B755e \
--genesis-keyper 0x346a9357D8EB6F0FbC4894ed6DBb1eCCA1051c09 \
--blocktime 1 \
--listen-address tcp://127.0.0.1:${TM_RPC_PORT} \
--listen-address tcp://0.0.0.0:${TM_RPC_PORT} \
--role validator

${BB} sed -i "/ValidatorPublicKey/c\ValidatorPublicKey = \"$(cat data/${validator_cmd}/config/priv_validator_pubkey.hex)\"" /config/keyper-${num}.toml
validator_id=$(cat data/${validator_cmd}/config/node_key.json.id)
validator_node=${validator_id}@${validator_cmd}:${TM_P2P_PORT}
validator_config_path=data/${validator_cmd}/config/config.toml

# share genesis
if [ $num -eq 0 ]; then
for destination in data/chain-seed/config/ data/chain-{1..3}-validator/config/ data/chain-{0..3}-sentry/config/; do
for destination in data/chain-seed/config/ data/chain-{1..3}-validator/config/; do
${BB} cp -v data/chain-0-validator/config/genesis.json "${destination}"
done
fi
done

seed_node=$(cat data/chain-seed/config/node_key.json.id)@chain-seed:${TM_P2P_PORT}

for num in 0 1 2 3; do
sentry_cmd=chain-$num-sentry
validator_cmd=chain-$num-validator

validator_id=$(cat data/${validator_cmd}/config/node_key.json.id)
validator_node=${validator_id}@${validator_cmd}:${TM_P2P_PORT}
sentry_node=$(cat data/${sentry_cmd}/config/node_key.json.id)@${sentry_cmd}:${TM_P2P_PORT}
# set validator publickey for keyper
${BB} sed -i "/ValidatorPublicKey/c\ValidatorPublicKey = \"$(cat data/${validator_cmd}/config/priv_validator_pubkey.hex)\"" /config/keyper-${num}.toml

# set seed node for sentry
${BB} sed -i "/^persistent_peers =/c\persistent_peers = \"${seed_node}\"" data/${sentry_cmd}/config/config.toml
# set validator node for sentry
${BB} sed -i "/^private_peer_ids =/c\private_peer_ids = \"${validator_id}\"" data/${sentry_cmd}/config/config.toml
${BB} sed -i "/^unconditional_peer_ids =/c\unconditional_peer_ids = \"${validator_id}\"" data/${sentry_cmd}/config/config.toml
${BB} sed -i "/^external_address =/c\external_address = \"${sentry_cmd}:${TM_P2P_PORT}\"" data/${sentry_cmd}/config/config.toml
# set seed node for chain bootstrap
${BB} sed -i "/^seeds =/c\seeds = \"${seed_node}\"" "${validator_config_path}"
# fix external address for docker internal communication
${BB} sed -i "/^external_address =/c\external_address = \"${validator_cmd}:${TM_P2P_PORT}\"" "${validator_config_path}"
# give a nice name
${BB} sed -i "/^moniker/c\moniker = \"${validator_cmd}\"" "${validator_config_path}"

# set sentry node for validator
${BB} sed -i "/^persistent_peers =/c\persistent_peers = \"${sentry_node}\"" data/${validator_cmd}/config/config.toml
${BB} sed -i "/^external_address =/c\external_address = \"${validator_cmd}:${TM_P2P_PORT}\"" data/${validator_cmd}/config/config.toml
done

$DC stop -t 30
6 changes: 1 addition & 5 deletions docker/04-bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@ source ./common.sh

echo "Submitting bootstrap transaction"

$DC run --rm --no-deps --entrypoint /rolling-shutter chain-0-validator bootstrap \
--deployment-dir /deployments/dockerGeth \
--ethereum-url http://geth:8545 \
--shuttermint-url http://chain-0-sentry:${TM_RPC_PORT} \
--signing-key 479968ffa5ee4c84514a477a8f15f3db0413964fd4c20b08a55fed9fed790fad
docker run --rm -it --network snapshutter_default -v /root/rolling-shutter/docker/config:/config -v /root/rolling-shutter/docker/data/bootstrap:/data rolling-shutter op-bootstrap --config /config/bootstrap.toml
9 changes: 7 additions & 2 deletions docker/05-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
source ./common.sh
set +ex

echo "Testing decryption key generation"
EPOCH_ID=$(LC_ALL=C tr -dc 'a-f0-9' </dev/urandom | head -c64)
json_body="{\"jsonrpc\": \"2.0\", \"method\": \"get_decryption_key\", \"id\": 1, \"params\": [\"1\", \"${EPOCH_ID}\"]}"
EON_ID=$($DC exec db psql -U postgres -d keyper-0 -t -c 'select max(eon) from eons;' | tr -d '[:space:]')
if [[ -z $EON_ID ]]; then
echo "No eonId found in keyper-0 db. Did you run bootstrap?"
exit 1
fi
json_body="{\"jsonrpc\": \"2.0\", \"method\": \"get_decryption_key\", \"id\": 1, \"params\": [\"${EON_ID}\", \"${EPOCH_ID}\"]}"
echo "Testing decryption key generation for eonId ${EON_ID} and epoch ${EPOCH_ID}"
curl -XGET http://localhost:8754/api/v1/rpc -d "${json_body}"
sleep 5
DECRYPTION_KEY_MSGS=$(${DC} logs snapshot | grep ${EPOCH_ID} | grep -c decryptionKey)
Expand Down
15 changes: 9 additions & 6 deletions docker/build-src/deploy_contracts/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
FROM node:16.16
FROM alpine/git AS builder

RUN mkdir /contracts
RUN date
RUN git clone --branch=docker_deploy_gnosis https://github.com/shutter-network/contracts /contracts

COPY /contracts/package*.json /contracts/
WORKDIR /contracts

RUN --mount=type=cache,target=/root/.npm npm install
#COPY /contracts /contracts

COPY /contracts /contracts
FROM ghcr.io/foundry-rs/foundry:latest AS runner
WORKDIR /contracts
COPY --from=builder /contracts /contracts

ENTRYPOINT ["npx", "hardhat", "--network", "dockerGeth"]
CMD ["deploy"]
RUN forge build
ENTRYPOINT ["forge", "script"]
2 changes: 1 addition & 1 deletion docker/build-src/geth/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ethereum/client-go:v1.10.20
FROM ethereum/client-go:v1.14.12

RUN apk add --no-cache curl

Expand Down
2 changes: 1 addition & 1 deletion docker/config.example/keyper-0.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DeploymentDir = "./deployments/dockerGeth/"
EthereumURL = "http://geth:8545/"

[Shuttermint]
ShuttermintURL = "http://chain-0-sentry:26657"
ShuttermintURL = "http://chain-0-validator:26657"
ValidatorPublicKey = '720accc33c2bce1319d12b5f23f81b39a33f487e21c4a4d7ca1e1f7954a24172'
EncryptionKey = 'e5c124eb4d3c13fa46532107b69b5abfa11e8aaf3a7a86d11ef370470834e076'
DKGPhaseLength = 8
Expand Down
2 changes: 1 addition & 1 deletion docker/config.example/keyper-1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DeploymentDir = "./deployments/dockerGeth/"
EthereumURL = "http://geth:8545/"

[Shuttermint]
ShuttermintURL = "http://chain-1-sentry:26657"
ShuttermintURL = "http://chain-1-validator:26657"
ValidatorPublicKey = '720accc33c2bce1319d12b5f23f81b39a33f487e21c4a4d7ca1e1f7954a24172'
EncryptionKey = '8972bbbcf5b4a9eaef0030b1eff64332e7188ff4dd523314176956b5c624ca8b'
DKGPhaseLength = 8
Expand Down
2 changes: 1 addition & 1 deletion docker/config.example/keyper-2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ DeploymentDir = "./deployments/dockerGeth/"
EthereumURL = "http://geth:8545/"

[Shuttermint]
ShuttermintURL = "http://chain-2-sentry:26657"
ShuttermintURL = "http://chain-2-validator:26657"
ValidatorPublicKey = '720accc33c2bce1319d12b5f23f81b39a33f487e21c4a4d7ca1e1f7954a24172'
EncryptionKey = 'ee014227e5b6209682f31c967b4a21c6617a02bc5f11f644f5f54f6d613906b9'
DKGPhaseLength = 8
Expand Down
2 changes: 1 addition & 1 deletion docker/config.example/keyper-3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ DeploymentDir = "./deployments/dockerGeth/"
EthereumURL = "http://geth:8545/"

[Shuttermint]
ShuttermintURL = "http://chain-3-sentry:26657"
ShuttermintURL = "http://chain-3-validator:26657"
ValidatorPublicKey = '8ad31f4e77c5092977d57e578b47dc23a86762933a4c09bcb055456805c84096'
EncryptionKey = '13c24d4a50e53bdb4cf8ae328491fd10fbf1bc0118ff6adad1340fa77eaf9c3c'
DKGPhaseLength = 8
Expand Down
26 changes: 26 additions & 0 deletions docker/config.gnosis/bootnode-0.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Peer identity: /p2p/12D3KooWJN7262vmnEQHkYG7VrZDwz9fMyJtHyvGp4XSenuUYfeJ
# Peer role: bootstrap

# whether to register handlers on the messages and log them
InstanceID = 0
ListenMessages = true

[P2P]
P2PKey = "CAESQKFtiMAqd2c8bQ/mfPStxViY970MNtWUVWdn44rUoQXAfv7ztSQ9nLeqliXrkuqKi3XUObyAfH+Py3eMbHFvIpM="
ListenAddresses = ["/ip4/0.0.0.0/tcp/23000"]
# Overwrite p2p boostrap nodes
CustomBootstrapAddresses = [
"/dns4/bootnode-0/tcp/23000/p2p/12D3KooWJN7262vmnEQHkYG7VrZDwz9fMyJtHyvGp4XSenuUYfeJ",
"/dns4/bootnode-1/tcp/23000/p2p/12D3KooWSayB2PEYpXtdk2dEqFaagoy8kDzmWpoD9DieuuzYdcBo"
]
DiscoveryNamespace = 'shutter-local'

[P2P.FloodSubDiscovery]
Enabled = true
Interval = 10
Topics = []

[Metrics]
Enabled = false
Host = '[::]'
Port = 9100
26 changes: 26 additions & 0 deletions docker/config.gnosis/bootnode-1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Peer identity: /p2p/12D3KooWSayB2PEYpXtdk2dEqFaagoy8kDzmWpoD9DieuuzYdcBo
# Peer role: bootstrap

# whether to register handlers on the messages and log them
InstanceID = 0
ListenMessages = true

[P2P]
P2PKey = "CAESQCywBzANmzk2gFd63qkQ8+PlZzy/IqK9Wuv5d6FB1cYh+SggYvQ9pBD5FPLqTbc7garDqgQUJz/6Gpi6Ssbcx44="
ListenAddresses = ["/ip4/0.0.0.0/tcp/23000"]
# Overwrite p2p boostrap nodes
CustomBootstrapAddresses = [
"/dns4/bootnode-0/tcp/23000/p2p/12D3KooWJN7262vmnEQHkYG7VrZDwz9fMyJtHyvGp4XSenuUYfeJ",
"/dns4/bootnode-1/tcp/23000/p2p/12D3KooWSayB2PEYpXtdk2dEqFaagoy8kDzmWpoD9DieuuzYdcBo"
]
DiscoveryNamespace = 'shutter-local'

[P2P.FloodSubDiscovery]
Enabled = true
Interval = 10
Topics = []

[Metrics]
Enabled = false
Host = '[::]'
Port = 9100
29 changes: 29 additions & 0 deletions docker/config.gnosis/bootnode0.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Peer identity: /p2p/12D3KooWPt2Eh4uTNw8smCNFs7PT68DXdVNyDrQEHFzzgnJWWdS3
# Peer role: bootstrap


# whether to register handlers on the messages and log them
ListenMessages = true

[P2P]
P2PKey = 'CAESQNfnoz3CQaZy/6rlfhHe48TksOc07kPiVe19hrnldjbH0PNnMHMeSJu9D9kd6MKcrc9OE0emziqRnBUdGCXW/XQ='
ListenAddresses = ['/ip4/0.0.0.0/tcp/0', '/ip4/0.0.0.0/udp/0/quic-v1', '/ip4/0.0.0.0/udp/0/quic-v1/webtransport', '/ip6/::/tcp/0', '/ip6/::/udp/0/quic-v1', '/ip6/::/udp/0/quic-v1/webtransport']
# Optional, addresses to be advertised to other peers instead of auto-detected ones.
AdvertiseAddresses = []
# Overwrite p2p boostrap nodes
CustomBootstrapAddresses = ['/ip4/127.0.0.1/tcp/2001/p2p/QmdfBeR6odD1pRKendUjWejhMd9wybivDq5RjixhRhiERg', '/ip4/127.0.0.1/tcp/2002/p2p/QmV9YbMDLDi736vTzy97jn54p43o74fLxc5DnLUrcmK6WP']
Environment = 'production'
# Must be unique for each instance id.
DiscoveryNamespace = 'shutter-42'
# Optional, to be set to true if running an access node
IsAccessNode = false

[P2P.FloodSubDiscovery]
Enabled = false
Interval = 10
Topics = []

[Metrics]
Enabled = false
Host = '[::]'
Port = 9100
29 changes: 29 additions & 0 deletions docker/config.gnosis/bootnode1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Peer identity: /p2p/12D3KooWEUQAo6evsiqAbwGaoXT4WcmLATdgikQ9w4KDmGNa4kK7
# Peer role: bootstrap


# whether to register handlers on the messages and log them
ListenMessages = true

[P2P]
P2PKey = 'CAESQEJ6NhABhjCtDfPfaPoAsLIq9UK9jdpxvQYODZmRTJwFRS0UsuQQY3/PX19cVqrc9pBXRiDTxQIcnVNNshXIBI4='
ListenAddresses = ['/ip4/0.0.0.0/tcp/0', '/ip4/0.0.0.0/udp/0/quic-v1', '/ip4/0.0.0.0/udp/0/quic-v1/webtransport', '/ip6/::/tcp/0', '/ip6/::/udp/0/quic-v1', '/ip6/::/udp/0/quic-v1/webtransport']
# Optional, addresses to be advertised to other peers instead of auto-detected ones.
AdvertiseAddresses = []
# Overwrite p2p boostrap nodes
CustomBootstrapAddresses = ['/ip4/127.0.0.1/tcp/2001/p2p/QmdfBeR6odD1pRKendUjWejhMd9wybivDq5RjixhRhiERg', '/ip4/127.0.0.1/tcp/2002/p2p/QmV9YbMDLDi736vTzy97jn54p43o74fLxc5DnLUrcmK6WP']
Environment = 'production'
# Must be unique for each instance id.
DiscoveryNamespace = 'shutter-42'
# Optional, to be set to true if running an access node
IsAccessNode = false

[P2P.FloodSubDiscovery]
Enabled = false
Interval = 10
Topics = []

[Metrics]
Enabled = false
Host = '[::]'
Port = 9100
8 changes: 8 additions & 0 deletions docker/config.gnosis/bootstrap.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
InstanceID = 42
# The op-geth JSON RPC endpoint
JSONRPCURL = 'http://geth:8545'
KeyperSetManager = "0x0000000000000000000000000000000000000000"
ByIndex = 1
KeyperSetFilePath = '/config/keyperset.json'
ShuttermintURL = 'http://chain:26657'
SigningKey = "0000000000000000000000000000000000000000000000000000000000000000"
32 changes: 32 additions & 0 deletions docker/config.gnosis/collator.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Note: for snapshot shutter, we don't need to run a collator!

# Peer identity: /p2p/12D3KooWFsVXBunDMNQZ8LLvS7BpY85Bop8isZaFAq6NVL7nLzUj
# Ethereum address: 0x2E135FE171fB6351026B75aF688a7F9689B66B87


InstanceID = 0
DatabaseURL = "postgres://postgres@db:5432/collator"
HTTPListenAddress = ':3000'
SequencerURL = "http://geth:8545/"
EpochDuration = '1s'
ExecutionBlockDelay = 5
BatchIndexAcceptenceInterval = 5

[P2P]
P2PKey = "CAESQDTb6IrZcY37WUI2Ld42H4ixyA7S/7ttXBUt0J9EwuPGWfMtbuNarlScRbqIz6Dm8jZqZWkpECDx8r8PwXB97ZQ="
ListenAddresses = ["/ip4/0.0.0.0/tcp/23000"]
# Overwrite p2p boostrap nodes
CustomBootstrapAddresses = [
"/dns4/bootnode-0/tcp/23000/p2p/12D3KooWJN7262vmnEQHkYG7VrZDwz9fMyJtHyvGp4XSenuUYfeJ",
"/dns4/bootnode-1/tcp/23000/p2p/12D3KooWSayB2PEYpXtdk2dEqFaagoy8kDzmWpoD9DieuuzYdcBo"
]

[Ethereum]

PrivateKey = "215ddd19b91c54252bb956c7f88e42122a61bd45a562d5bae38bc2328a9b52d0"
# The JSON RPC endpoint where the contracts are accessible
ContractsURL = "http://geth:8545/"
# Contract source directory
DeploymentDir = "/deployments/dockerGeth/"
# The layer 1 JSON RPC endpoint
EthereumURL = "http://geth:8545/"
8 changes: 8 additions & 0 deletions docker/config.gnosis/grafana/provisioning/datasources/vm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: 1

datasources:
- name: VictoriaMetrics
type: victoriametrics-datasource
access: proxy
url: http://metrics:8428
isDefault: true
Loading