Skip to content

Commit 72c56da

Browse files
authored
Merge pull request #509 from shutter-network/manual-local-deployment
Add scripts to run rolling shutter locally
2 parents f861c42 + d360533 commit 72c56da

File tree

13 files changed

+331
-0
lines changed

13 files changed

+331
-0
lines changed

play/manual/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Manual Setup
2+
3+
This directory contains a few scripts and corresponding config file templates to
4+
semi-manually setup and run a set of keypers locally. Basic instructions:
5+
6+
0. Install requirements with `make install-asdf-plugins` and
7+
`make install-asdf`.
8+
1. Build `rolling-shutter` with `make -C ../../rolling-shutter build`.
9+
2. Run a postgres database, e.g. with `initdb -D work/db/` and
10+
`process-compose up` in the `/play` directory.
11+
3. Set the variable `private_key` in `ethereum.sh` to a private key with funds
12+
on Chiado.
13+
4. Clone the repos
14+
[gnosh-contracts](https://github.com/shutter-network/gnosh-contracts) and
15+
[shop-contracts](https://github.com/shutter-network/shop-contracts) in a
16+
common directory, including their submodules
17+
(`git submodule update --init --recursive`). Specify the relative path to
18+
this directory in the variable `contracts_root_dir`.
19+
5. Run `./ethereum.sh`. This will output a set of contract addresses.
20+
6. Copy and paste the contract addresses into the configuration files
21+
`keyper-0.toml`, `keyper-1.toml`, and `keyper-2.toml` under the section
22+
`[Gnosis.Contracts]`. Additionally, copy the keyper set manager address into
23+
`op-bootstrap-config.toml` under `KeyperSetManager`.
24+
25+
> Tip: A newly deployed validator registry won't have any registrations, so
26+
> keypers won't produce any keys. Oftentimes it is therefore helpful to use the
27+
> official validator registry on Chiado instead.
28+
29+
7. Run `./initdb.sh`
30+
8. Run `./p2p.sh` and keep it running.
31+
9. Run `./shuttermint.sh` and keep it running.
32+
10. Wait until the activation block of the first keyper set is reached. The time
33+
it takes is defined by `activation_delta` defined in `ethereum.sh`.
34+
11. Run the keypers with `./k.sh 0`, `./k.sh 1`, and `./k.sh 2`. Optionally, set
35+
the `ROLLING_SHUTTER_LOGLEVEL` environment variable to
36+
`:debug,dht:info,pubsub:info,swarm:info` to get reasonable log outputs.
37+
38+
If everything was successful, the keypers should start immediately with eon key
39+
generation and once this succeeded decryption keys should be produced for every
40+
Chiado slot with registered validator. Helpful log messages are:
41+
42+
- `"DKG process succeeded"`
43+
- `"DKG process failed"`
44+
- `"skipping slot as proposer is not registered"`
45+
- `"sending decryption trigger"`.

play/manual/ethereum.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
private_key=
6+
rpc_url=https://rpc.chiadochain.net/
7+
8+
keypers=0x9A1ba2D523AAB8f7784870B639924103d25Bb714,0x7b79Ba0f76eE49F6246c0034A2a3445C281a67EB,0x62F6DC5638250bD9edE84DFBfa54efA263186a4a
9+
threshold=2
10+
activation_delta=60
11+
12+
contracts_root_dir=../../../
13+
shop_contracts_dir=shop-contracts
14+
gnosh_contracts_dir=gnosh-contracts
15+
16+
cd $contracts_root_dir
17+
18+
# deploy keyper set manager and key broadcast contract
19+
cd $shop_contracts_dir
20+
function deploy_shop() {
21+
export PRIVATE_KEY=$private_key
22+
forge script script/DeployGnosis.s.sol --rpc-url $rpc_url --broadcast
23+
}
24+
deploy_shop_output=$(deploy_shop)
25+
26+
# extract contract addresses
27+
extract_address() {
28+
local contract_name="$1"
29+
local output="$2"
30+
local address=""
31+
address=$(echo "$output" | grep -o "$contract_name: 0x[[:xdigit:]]\{40\}" | cut -d' ' -f2)
32+
echo "$address"
33+
}
34+
35+
keyper_set_manager_address=$(extract_address "keyperSetManager" "$deploy_shop_output")
36+
key_broadcast_address=$(extract_address "keyBroadcastContract" "$deploy_shop_output")
37+
38+
function add_empty_keyper_set() {
39+
export PRIVATE_KEY=$private_key
40+
export KEYPER_ADDRESSES=
41+
export THRESHOLD=0
42+
export ACTIVATION_DELTA=$activation_delta
43+
export KEYPERSETMANAGER_ADDRESS=$keyper_set_manager_address
44+
export KEYBROADCAST_ADDRESS=$key_broadcast_address
45+
forge script script/AddKeyperSet.s.sol --rpc-url $rpc_url --broadcast
46+
}
47+
add_empty_keyper_set
48+
49+
# add keyper set
50+
function add_keyper_set() {
51+
export PRIVATE_KEY=$private_key
52+
export KEYPER_ADDRESSES=$keypers
53+
export THRESHOLD=$threshold
54+
export ACTIVATION_DELTA=$activation_delta
55+
export KEYPERSETMANAGER_ADDRESS=$keyper_set_manager_address
56+
export KEYBROADCAST_ADDRESS=$key_broadcast_address
57+
forge script script/AddKeyperSet.s.sol --rpc-url $rpc_url --broadcast
58+
}
59+
add_keyper_set_output=$(add_keyper_set)
60+
61+
eon_key_publish_address=$(extract_address "eonKeyPublish" "$add_keyper_set_output")
62+
63+
# deploy sequencer contract
64+
cd ../$gnosh_contracts_dir
65+
function deploy_gnosh() {
66+
export DEPLOY_KEY=$PRIVATE_KEY
67+
export ETHERSCAN_API_KEY=
68+
forge script script/deploySequencer.s.sol --rpc-url $rpc_url --broadcast
69+
}
70+
deploy_gnosh_output=$(deploy_gnosh)
71+
72+
sequencer_address=$(extract_address "Sequencer" "$deploy_gnosh_output")
73+
validator_registry_address=$(extract_address "ValidatorRegistry" "$deploy_gnosh_output")
74+
75+
echo "KeyperSetManager = '$keyper_set_manager_address'"
76+
echo "KeyBroadcastContract = '$key_broadcast_address'"
77+
echo "Sequencer = '$sequencer_address'"
78+
echo "ValidatorRegistry = '$validator_registry_address'"
79+
echo "EonKeyPublish = '$eon_key_publish_address'"
80+
81+
echo "contracts deployed and configured"

play/manual/initdb.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
dropdb --if-exists keyper-db-0
4+
dropdb --if-exists keyper-db-1
5+
dropdb --if-exists keyper-db-2
6+
createdb keyper-db-0
7+
createdb keyper-db-1
8+
createdb keyper-db-2
9+
./rolling-shutter gnosiskeyper initdb --config keyper-0.toml
10+
./rolling-shutter gnosiskeyper initdb --config keyper-1.toml
11+
./rolling-shutter gnosiskeyper initdb --config keyper-2.toml

play/manual/k.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
./rolling-shutter gnosiskeyper --config keyper-"$1".toml

play/manual/keyper-0.toml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Peer identity: /p2p/12D3KooWLyURWEKUX9uGnx8wMTR7svUneR7GqE7SzRVU5Gs2cdk6
2+
# Ethereum address: 0x9A1ba2D523AAB8f7784870B639924103d25Bb714
3+
4+
InstanceID = 42
5+
DatabaseURL = "postgres:///keyper-db-0"
6+
BeaconAPIURL = 'https://chiado-node.staging.shutter.network/consensus'
7+
HTTPEnabled = true
8+
HTTPListenAddress = ":24000"
9+
MaxNumKeysPerMessage = 500
10+
11+
[P2P]
12+
P2PKey = 'CAESQAn5BbjgcwTR6bjlU+txNoG1fPlBbuwpd7uQdn1DRCCLpcXa/mKi0yp3zZinCHYopr5nWylcTDdfIpWPrgXUT1s='
13+
ListenAddresses = ["/ip4/127.0.0.1/tcp/23103"]
14+
CustomBootstrapAddresses = ['/ip4/127.0.0.1/tcp/2001/p2p/12D3KooWMyutShWdqYj7fre4Vjuq2QnCTb26Ki1KpyDyVsrmKeki']
15+
Environment = "local"
16+
DiscoveryNamespace = "shutter-42"
17+
18+
[Gnosis]
19+
EncryptedGasLimit = 1000000
20+
MinGasPerTransaction = 21000
21+
MaxTxPointerAge = 5
22+
SecondsPerSlot = 5
23+
SlotsPerEpoch = 16
24+
GenesisSlotTimestamp = 1665396300
25+
SyncStartBlockNumber = 0
26+
27+
[Gnosis.Node]
28+
PrivateKey = 'dcb23da56656b3c8a11e2b4cdd92f430c500862f7f7fc762807d11b734e9500c'
29+
ContractsURL = "https://chiado-node.staging.shutter.network/execution"
30+
DeploymentDir = './deployments/localhost/'
31+
EthereumURL = "wss://chiado-node.staging.shutter.network/execution"
32+
33+
[Gnosis.Contracts]
34+
KeyperSetManager = '0x058062B7d74ba6B4Af1eE22833579C67adC17175'
35+
KeyBroadcastContract = '0x74060a34F6ac647C29735A245617d36caD94d02C'
36+
Sequencer = '0x62c70cf31AD1005944b66A2e539a11792D930998'
37+
ValidatorRegistry = '0x716Be4F8C84989efF385277dad4f27B393330b99'
38+
EonKeyPublish = '0xF087BfBC3D7820B23298f7a7b77387BfC55eD9C6'
39+
40+
[Shuttermint]
41+
ShuttermintURL = 'http://localhost:26657'
42+
ValidatorPublicKey = 'e8555b1be0a27e05498793aa65e2630b43916bacfa6b09a73594c3aec35c6f6c'
43+
EncryptionKey = '5fa2346f12abb947c1cda3b6a91d7f4702b524c64f35fe07e20b913d5fa8d914'
44+
DKGPhaseLength = 8
45+
DKGStartBlockDelta = 5
46+
47+
[Metrics]
48+
Enabled = true
49+
Host = '[::]'
50+
Port = 9100

play/manual/keyper-1.toml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Peer identity: /p2p/12D3KooWRmoxBapB4EBZDK74R4yGwjL8uhgrPiRGRmNnbQuDMt7U
2+
# Ethereum address: 0x7b79Ba0f76eE49F6246c0034A2a3445C281a67EB
3+
4+
InstanceID = 42
5+
DatabaseURL = "postgres:///keyper-db-1"
6+
BeaconAPIURL = 'https://chiado-node.staging.shutter.network/consensus'
7+
HTTPEnabled = true
8+
HTTPListenAddress = ":24001"
9+
MaxNumKeysPerMessage = 500
10+
11+
[P2P]
12+
P2PKey = 'CAESQOvglAGkrDFYcA+rhLIEDdRK37Ep4R0l0UbNKjpSsQJW7RNm3P3AzGFActUO9528nhy7ocP6fLEnEpMKF0Ssr8M='
13+
ListenAddresses = ["/ip4/127.0.0.1/tcp/23101"]
14+
CustomBootstrapAddresses = ['/ip4/127.0.0.1/tcp/2001/p2p/12D3KooWMyutShWdqYj7fre4Vjuq2QnCTb26Ki1KpyDyVsrmKeki']
15+
Environment = "local"
16+
DiscoveryNamespace = "shutter-42"
17+
18+
[Gnosis]
19+
EncryptedGasLimit = 1000000
20+
MinGasPerTransaction = 21000
21+
MaxTxPointerAge = 5
22+
SecondsPerSlot = 5
23+
SlotsPerEpoch = 16
24+
GenesisSlotTimestamp = 1665396300
25+
SyncStartBlockNumber = 0
26+
27+
[Gnosis.Node]
28+
PrivateKey = '00b4a53228e3761ad78bd376b8293f19af36777f71d8e55a61975f8eecd8c1c1'
29+
ContractsURL = "https://chiado-node.staging.shutter.network/execution"
30+
DeploymentDir = './deployments/localhost/'
31+
EthereumURL = "wss://chiado-node.staging.shutter.network/execution"
32+
33+
[Gnosis.Contracts]
34+
KeyperSetManager = '0x058062B7d74ba6B4Af1eE22833579C67adC17175'
35+
KeyBroadcastContract = '0x74060a34F6ac647C29735A245617d36caD94d02C'
36+
Sequencer = '0x62c70cf31AD1005944b66A2e539a11792D930998'
37+
ValidatorRegistry = '0x716Be4F8C84989efF385277dad4f27B393330b99'
38+
EonKeyPublish = '0xF087BfBC3D7820B23298f7a7b77387BfC55eD9C6'
39+
40+
[Shuttermint]
41+
ShuttermintURL = 'http://localhost:26657'
42+
ValidatorPublicKey = 'af5946acc59418ebb9d706811c0fd313d418ce64507021c249a114605a146dbb'
43+
EncryptionKey = '42211c0cdf374a78fde38d8ef9ac6b8370133bd6594dcc37ccaf1598e6cdee0d'
44+
DKGPhaseLength = 8
45+
DKGStartBlockDelta = 5
46+
47+
[Metrics]
48+
Enabled = true
49+
Host = '[::]'
50+
Port = 9101

play/manual/keyper-2.toml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Peer identity: /p2p/12D3KooWKm6Daxect5KtqgF7HeF1woSb16xQDGXThaKxtyngEHaG
2+
# Ethereum address: 0x62F6DC5638250bD9edE84DFBfa54efA263186a4a
3+
4+
InstanceID = 42
5+
DatabaseURL = "postgres:///keyper-db-2"
6+
BeaconAPIURL = 'https://chiado-node.staging.shutter.network/consensus'
7+
HTTPEnabled = true
8+
HTTPListenAddress = ":24002"
9+
MaxNumKeysPerMessage = 500
10+
11+
[P2P]
12+
P2PKey = 'CAESQIaR6iJCaJcmXwNyze/UpmAvKK2yQybw+sH7OG9HKbeek74XSoI3XGj+ZLknktVJoxeSTf5fti/CX67DcHvZXOE='
13+
ListenAddresses = ["/ip4/127.0.0.1/tcp/23102"]
14+
CustomBootstrapAddresses = ['/ip4/127.0.0.1/tcp/2001/p2p/12D3KooWMyutShWdqYj7fre4Vjuq2QnCTb26Ki1KpyDyVsrmKeki']
15+
Environment = "local"
16+
DiscoveryNamespace = "shutter-42"
17+
18+
[Gnosis]
19+
EncryptedGasLimit = 1000000
20+
MinGasPerTransaction = 21000
21+
MaxTxPointerAge = 5
22+
SecondsPerSlot = 5
23+
SlotsPerEpoch = 16
24+
GenesisSlotTimestamp = 1665396300
25+
SyncStartBlockNumber = 0
26+
27+
[Gnosis.Node]
28+
PrivateKey = 'a4e901b1df81ff8fc5fa77f5bf0c15a4c8410e85fcaf19fbec47a2241b9d65d6'
29+
ContractsURL = "https://chiado-node.staging.shutter.network/execution"
30+
DeploymentDir = './deployments/localhost/'
31+
EthereumURL = "wss://chiado-node.staging.shutter.network/execution"
32+
33+
[Gnosis.Contracts]
34+
KeyperSetManager = '0x058062B7d74ba6B4Af1eE22833579C67adC17175'
35+
KeyBroadcastContract = '0x74060a34F6ac647C29735A245617d36caD94d02C'
36+
Sequencer = '0x62c70cf31AD1005944b66A2e539a11792D930998'
37+
ValidatorRegistry = '0x716Be4F8C84989efF385277dad4f27B393330b99'
38+
EonKeyPublish = '0xF087BfBC3D7820B23298f7a7b77387BfC55eD9C6'
39+
40+
[Shuttermint]
41+
ShuttermintURL = 'http://localhost:26657'
42+
ValidatorPublicKey = 'df359cd93fe4570db05afb626fd9055802834ed5ca1267ae288e1fd36ee69666'
43+
EncryptionKey = 'ac12d8fbf00461be79021e378f230d5dd93ffa24eb156785a13c010d0809a633'
44+
DKGPhaseLength = 8
45+
DKGStartBlockDelta = 5
46+
47+
[Metrics]
48+
Enabled = true
49+
Host = '[::]'
50+
Port = 9102

play/manual/op-bootstrap-config.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
InstanceID = 42
2+
JSONRPCURL = 'https://rpc.chiadochain.net/'
3+
KeyperSetManager = '0x058062B7d74ba6B4Af1eE22833579C67adC17175'
4+
ByIndex = 1
5+
KeyperSetFilePath = 'keyperset.json'
6+
ShuttermintURL = 'http://127.0.0.1:26657'
7+
SigningKey = '479968ffa5ee4c84514a477a8f15f3db0413964fd4c20b08a55fed9fed790fad'

play/manual/p2p.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
./rolling-shutter p2pnode --config p2p_bootstrap.toml

play/manual/p2p_bootstrap.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Peer identity: /p2p/12D3KooWMyutShWdqYj7fre4Vjuq2QnCTb26Ki1KpyDyVsrmKeki
2+
# Peer role: bootstrap
3+
4+
5+
# whether to register handlers on the messages and log them
6+
ListenMessages = true
7+
SigningKey = "479968ffa5ee4c84514a477a8f15f3db0413964fd4c20b08a55fed9fed790fad"
8+
9+
[P2P]
10+
P2PKey = 'CAESQP97SvcBcpQ+FlDQ2+unlt2/sQWnY4MLaG8IFBCkCwR7tL5Vy3RFatDpX4Sy9fMvjLl7vM/hzqQxi9C6liPRL8s='
11+
ListenAddresses = ['/ip4/127.0.0.1/tcp/2001']
12+
# Overwrite p2p boostrap nodes
13+
CustomBootstrapAddresses = ['/ip4/127.0.0.1/tcp/2001/p2p/12D3KooWMyutShWdqYj7fre4Vjuq2QnCTb26Ki1KpyDyVsrmKeki']
14+
Environment = 'local'
15+
DiscoveryNamespace = "shutter-42"

0 commit comments

Comments
 (0)