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

Provide a local development ("local devnet") configuration as a start. #446

Merged
merged 3 commits into from
Oct 26, 2023
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
24 changes: 22 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,33 @@ RUN addgroup --system entropy \
entropy \
&& chown -R entropy:entropy /srv/entropy

# Despite statically linking our binaries, we will still need these
# libraries to process the /etc/nsswitch.conf file and perform DNS
# lookups, as we've built with glibc, but Alpine provides musl libc.
# This is a notorious issue in GNU glibc, currently without a fix:
# https://sourceware.org/bugzilla/show_bug.cgi?id=27959
COPY --from=build \
/lib/x86_64-linux-gnu/libnss_* \
/lib/x86_64-linux-gnu/libc.so.6 \
/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 \
/lib/x86_64-linux-gnu/libresolv.so.2 \
/lib/x86_64-linux-gnu/

# Lastly, we copy our own files into the final container image stage.
COPY --from=build --chown=entropy:entropy --chmod=554 /usr/local/bin/${PACKAGE} /usr/local/bin/${PACKAGE}
COPY --chown=entropy:entropy --chmod=554 bin/entrypoint.sh /usr/local/bin/entrypoint.sh

# Don't run as the `root` user within the container.
USER entropy

###
# Describe the available ports to expose.
##
# Describe the available ports to expose for `server`.
###
# TSS server's REST-style HTTP API port.
EXPOSE 3001
###
# Describe the available ports to expose for `entropy`.
###
# Substrate's default Prometheus endpoint.
EXPOSE 9615
# Substrate's default RPC port.
Expand Down
52 changes: 26 additions & 26 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ secrets:

services:
# Threshold Signature Scheme server
# In a local devnet setup, for now, this is "Alice's server."
tss-server:
# In a local devnet setup, for now, this is "Alice's TSS server."
alice-tss-server:
build:
args:
PACKAGE: server
Expand All @@ -34,11 +34,11 @@ services:
- "--threshold-url"
- "0.0.0.0:3001"
- "--chain-endpoint"
- "ws://chain-node:9944"
- "ws://alice-chain-node:9944"

# Sometimes also called simply a "chain," or a "validator."
# In a local devnet setup, for now, this is "Alice's chain."
chain-node:
alice-chain-node:
build:
ssh:
- default
Expand All @@ -47,32 +47,35 @@ services:
tags:
- entropy:chain-node
depends_on:
- tss-server
- alice-tss-server
ports:
# Enables other chain nodes speak to the validator.
# We comment this out because we're working only within
# the Docker network layer, not the host's network stack.
# Enables other chain nodes speak to the validator. We comment
# this out because we're working only within the Docker network
# layer, not the host's network stack. I.e., the port is open
# locally, but we do not publish it to the Docker host itself.
#- "127.0.0.1:30333:30333/tcp" # P2P Port.
# Enables network clients to speak to the node's API.
- "127.0.0.1:9944:9944/tcp" # RPC Port.
# Enables network clients to speak to the chain node's REST API.
- "127.0.0.1:9944:9944/tcp" # "RPC Port."
command:
- "--alice"
- "--chain"
- "local-devnet"
- "--alice" # Shortcut for `--name Alice --validator`
- "--base-path"
- ".entropy/alice"
- "--rpc-port"
- "9944"
- "--unsafe-rpc-external" # Intentional, for TSS's access.
- "--rpc-cors"
- "all"
- "--validator" # This is what makes the node a validator.
- "--node-key=0000000000000000000000000000000000000000000000000000000000000001"
- "--tss-server-endpoint"
- "http://tss-server:3001"
- "http://alice-tss-server:3001"

bob-tss:
# "Bob's TSS server."
bob-tss-server:
image: entropy:tss-server
depends_on:
- tss-server
- alice-tss-server
ports:
- "127.0.0.1:3002:3001/tcp"
command:
Expand All @@ -82,28 +85,25 @@ services:
- "--chain-endpoint"
- "ws://bob-chain-node:9944"

# "Bob's chain node."
bob-chain-node:
image: entropy:chain-node
depends_on:
- bob-tss
- bob-tss-server
ports:
# Enables other chain nodes speak to the validator.
# We comment this out because we're working only within
# the Docker network layer, not the host's network stack.
#- "127.0.0.1:30333:30333/tcp" # P2P Port.
# Enables network clients to speak to the node's API.
- "127.0.0.1:9945:9944/tcp" # RPC Port.
- "127.0.0.1:9945:9944/tcp"
command:
- "--bob"
- "--chain"
- "local-devnet"
- "--bob" # Shortcut for `--name Bob --validator`
- "--base-path"
- ".entropy/bob"
- "--rpc-port"
- "9944"
- "--unsafe-rpc-external" # Intentional, for TSS's access.
- "--rpc-cors"
- "all"
- "--validator" # This is what makes the node a validator.
- "--bootnodes"
- "/dns4/chain-node/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp"
- "/dns4/alice-chain-node/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp"
- "--tss-server-endpoint"
- "http://bob-tss:3001"
- "http://bob-tss-server:3001"
13 changes: 11 additions & 2 deletions node/cli/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use sp_consensus_babe::AuthorityId as BabeId;
use sp_core::{crypto::UncheckedInto, sr25519};

use crate::chain_spec::{
authority_keys_from_seed, devnet_genesis, get_account_id_from_seed, testing, testnet_genesis,
authority_keys_from_seed, devnet_genesis, get_account_id_from_seed, local_devnet_genesis,
testing, testnet_genesis,
};

pub fn devnet_config_genesis() -> RuntimeGenesisConfig {
Expand Down Expand Up @@ -225,7 +226,15 @@ pub fn development_config_genesis() -> RuntimeGenesisConfig {
)
}

pub fn testing_config_genesis() -> RuntimeGenesisConfig {
pub fn local_devnet_config_genesis() -> GenesisConfig {
vitropy marked this conversation as resolved.
Show resolved Hide resolved
local_devnet_genesis(
vec![authority_keys_from_seed("Alice"), authority_keys_from_seed("Bob")],
vec![],
get_account_id_from_seed::<sr25519::Public>("Alice"),
)
}

pub fn testing_config_genesis() -> GenesisConfig {
testing(
vec![authority_keys_from_seed("Alice"), authority_keys_from_seed("Bob")],
vec![],
Expand Down
20 changes: 15 additions & 5 deletions node/cli/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ pub struct RemarkBuilder {

impl RemarkBuilder {
/// Creates a new [`Self`] from the given client.
pub fn new(client: Arc<FullClient>) -> Self { Self { client } }
pub fn new(client: Arc<FullClient>) -> Self {
Self { client }
}
}

impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
fn pallet(&self) -> &str { "system" }
fn pallet(&self) -> &str {
"system"
}

fn extrinsic(&self) -> &str { "remark" }
fn extrinsic(&self) -> &str {
"remark"
}

fn build(&self, nonce: u32) -> std::result::Result<OpaqueExtrinsic, &'static str> {
let acc = Sr25519Keyring::Bob.pair();
Expand Down Expand Up @@ -61,9 +67,13 @@ impl TransferKeepAliveBuilder {
}

impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
fn pallet(&self) -> &str { "balances" }
fn pallet(&self) -> &str {
"balances"
}

fn extrinsic(&self) -> &str { "transfer_keep_alive" }
fn extrinsic(&self) -> &str {
"transfer_keep_alive"
}

fn build(&self, nonce: u32) -> std::result::Result<OpaqueExtrinsic, &'static str> {
let acc = Sr25519Keyring::Bob.pair();
Expand Down
Loading