Skip to content

Commit

Permalink
Remove duplicate baker-id option.
Browse files Browse the repository at this point in the history
It has historical use, but it is no longer relevant.
  • Loading branch information
abizjak committed Jan 21, 2021
1 parent f04ea4f commit be406fb
Show file tree
Hide file tree
Showing 9 changed files with 203 additions and 164 deletions.
27 changes: 16 additions & 11 deletions concordium-node/BUILD.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The build process for the rust component
# The build process configuration

The [build.rs](./build.rs) script links with a number of Haskell libraries and
supports a number of configuration options that can be configured in two
Expand All @@ -9,11 +9,12 @@ different ways, either via environment variables or Cargo features.
The package supports the following features

- `static`: This feature enables linking with static Haskell libraries.
They are expected to be available in `./deps/static-libs/linux/vanilla`, i.e. in that subdirectory of this directory.
The `download-static-libraries.sh` script from the p2p-client repository will download them into the correct location.
They are expected to be available in `../deps/static-libs/linux/vanilla`, i.e. in that subdirectory of this directory.
The [../scripts/download-static-libs.sh](../scripts/download-static-libs.sh)`
script will download them into the correct location.

- `profiling`: This will link with Haskell libraries built with profiling support. This option implies `static`, with the difference
that the libraries must be available in `./deps/static-libs/linux/profiling`.
that the libraries must be available in `../deps/static-libs/linux/profiling`.

By default no features are enabled.

Expand All @@ -22,12 +23,9 @@ By default no features are enabled.
Environment variables only apply to the default build. This links with shared Haskell libraries.

- `CONCORDIUM_HASKELL_ROOT` should, if present, be a directory containing
- libHSConcordium-0.1.0.0
- libHSconcordium-crypto-0.1.0.0
- libHSglobalstate-types-0.1.0.0
- libHSglobalstate-0.1.0.0
- libHSconcordium-consensus-0.1.0.0
- libHSconcordium-base-0.1.0.0
- libHSlmdb-0.2.5
- libHSscheduler-0.1.0.0

This only applies to non-windows platforms. It is not used on other platforms.
On Windows the Concordium haskell package is built with a `standalone` option which embeds all dependent libraries into one single DLL.
Expand All @@ -43,5 +41,12 @@ Environment variables only apply to the default build. This links with shared Ha
-- --print-libdir`.


Note that [build.rs](./build.rs) will not automatically build the Haskell
dependencies. This should be done before by running `stack build`.
## CAVEATS

Note that [build.rs](./build.rs) **will not** automatically build the Haskell
dependencies. This should be done before by running `stack build` inside
[../concordium-consensus/](../concordium-consensus/) or running

```console
stack --stack-yaml ../concordium-consensus/stack.yaml build
```
196 changes: 70 additions & 126 deletions concordium-node/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# P2P Layer implementation in Rust
`master` [![master pipeline status](https://gitlab.com/Concordium/p2p-client/badges/master/pipeline.svg)](https://gitlab.com/Concordium/p2p-client/commits/master) `develop` [![develop pipeline status](https://gitlab.com/Concordium/p2p-client/badges/develop/pipeline.svg)](https://gitlab.com/Concordium/p2p-client/commits/develop)
# Concordium node implementation

`master` [![master pipeline status](https://gitlab.com/Concordium/concordium-node/badges/master/pipeline.svg)](https://gitlab.com/Concordium/concordium-node/commits/master).

## General usage information
This repository relies on git submodules for internal component dependencies, so do remember to clone recursively or use `git submodule update --init --recursive` after having cloned it.
This repository relies on git submodules for some internal and external component dependencies.
Do remember to clone recursively or use `git submodule update --init --recursive` after having cloned it.

## Dependencies to build the project
* Rust (stable 1.45.2 for using static libraries)
Expand All @@ -17,7 +19,7 @@ This repository relies on git submodules for internal component dependencies, so
* PostGreSQL >= 10

### Optional dependencies
* Stack (and GHC-8.8.4, if not building using static libraries)
* [Haskell stack](https://docs.haskellstack.org/en/stable/README/) if **not** building using static libraries
* capnp (for running `s11n_capnp` enabled benches only)

## Supported features
Expand All @@ -38,147 +40,89 @@ This repository relies on git submodules for internal component dependencies, so

## Building the node

See instructions in
[consensus](./deps/internal/consensus/consensus-rust/README.md) for how to link
the node.

## Setting up basic local build environment
Install the needed dependencies from the list above, and run the script (requires that the user executing is has sudo privileges) `scripts/local-setup-unix-deps.sh` and pay special attention to setting the right version of GHC (see [build scripts](/scripts/local-setup-unix-deps.sh#L28) for details).

Alternatively use `--features=static` to build statically against the haskell dependencies (only available on Linux, and requries that you download them using [scripts/download-static-libs.sh](/scripts/download-static-libs.sh) before first compilation, and whenever the pointer to any internal dependencies are updated).

## Installing genesis data
Unpack the relevant set of genesis data and private baker data from [genesis-data/](/genesis-data) to the correct OS folder (e.g. on Linux this would be `$HOME/.local/share/concordium`). This determines how many bakers you need to run for the network to be able to work properly.

## Running the library as a binary (usable via gRPC)
```bash
$> cargo run -- --debug
```

## Running all tests
```bash
$> cargo test --all
```
The [build.rs](./build.rs) script links with a number of Haskell libraries and
supports a number of configuration options that can be configured in two
different ways, either via environment variables or Cargo features.

## Obtaining documentation
The output is placed in `target/doc` by default.
```bash
$> cargo doc
```
### Features

## Nix
Currently this project only sports support for Nix on Linux platforms.
### Development
All `zsh` wrapper functions wrap around `nix-shell`, and if dropping into a `nix-shell` directly remember to use the cargo flag `--features=static` to build against the static libraries (`nix-shell` will automatically pull these down from S3).
### Install binaries as a package
```bash
$> scripts/download-static-libs.sh
$> nix-env -f . -i
```
The package supports the following features related to linking with the Haskell component.

## Docker-Compose
### Building docker images
To build the stable image built in a Jenkins pipeline (it gets tagged `latest`, if not changed in the line shown below, so it matches the image hosted on docker-hub - and as the layers will have a newer version, it won't download from docker-hub unless the locally built image is removed via e.g. `docker image rmi ..`). It passes the local `ssh-agent` into the docker build environment for the needed stages to download internal crates with git directly. This image builds on `192549843005.dkr.ecr.eu-west-1.amazonaws.com/concordium/base` so make sure to have either built this locally (check [devops:base-images/build-base.sh](https://gitlab.com/Concordium/devops/blob/master/base-images/build-base-docker.sh) for the syntax and current version), or have access to AWS ECR to pull it.
```bash
$> git clone -b master --single-branch [email protected]:Concordium/tools/baker_id_gen.git baker_id_gen # Only needed once, as it's a vital component to scaling the bakers inside docker-compose
$> scripts/download-genesis-data.sh
$> scripts/download-genesis-complementary-bundle.sh
$> echo $(cd deps/internal/consensus && git rev-parse HEAD) > CONSENSUS_VERSION
$> DOCKER_BUILDKIT=1 docker build -f scripts/dev-client.Dockerfile -t concordium/dev-client:latest --ssh default . --no-cache
```
### Latest stable from master branch
For a local docker compose setup, a docker-compose.yml file has been provided in the root of this repository. It uses a image hosted in Docker hub built automatically upon push to the master branch.
- `static`: This feature enables linking with static Haskell libraries.
They are expected to be available in `../deps/static-libs/linux/vanilla`.
The [../scripts/download-static-libs.sh](../scripts/download-static-libs.sh)`
script will download them into the correct location.

For the most simple and common setup, simply run the below command in the root of the checked out repository
```bash
$> NUM_BAKERS=5 DESIRED_PEERS=4 docker-compose up --scale baker=5 --force-recreate
```
- `profiling`: This will link with Haskell libraries built with profiling support. This option implies `static`, with the difference
that the libraries must be available in `../deps/static-libs/linux/profiling`.

By default none of these features are enabled.

For more complicated setups the EXTRA_ARGS environment variable can be set.
### Environment variables

### Latest unstable from develop branch
For a local docker compose setup, a docker-compose.develop.yml file has been provided in the root of this repository. It uses a image hosted in Docker hub built automatically upon push to the develop branch.
Environment variables only apply to the default build. This links with shared Haskell libraries.

For the most simple and common setup, simply run the below command in the root of the checked out repository
```bash
$> NUM_BAKERS=5 DESIRED_PEERS=4 docker-compose -f docker-compose.develop.yml up --scale baker=5 --force-recreate
```
- `CONCORDIUM_HASKELL_ROOT` should, if present, be a directory containing
- libHSconcordium-consensus-0.1.0.0.so
- libHSconcordium-base-0.1.0.0.so
- libHSlmdb-0.2.5.so

### Latest debug from custom branch
For a local docker compose setup, a docker-compose.debug.yml file has been provided in the root of this repository. It uses a image hosted in Docker hub built manually from a specific branch. These builds must be considered extremely volatile!
This only applies to non-windows platforms. It is not used on other platforms.
On Windows the Concordium haskell package is built with a `standalone` option which embeds all dependent libraries into one single DLL.
This option does not work on linux, hence the more elaborate linking process.

For the most simple and common setup, simply run the below command in the root of the checked out repository
```bash
$> NUM_BAKERS=5 DESIRED_PEERS=4 docker-compose -f docker-compose.debug.yml up --scale baker=5 --force-recreate
```
If this flag is not present the build script will try to automatically discover all the Haskell libraries by using `stack path`.

### Latest debug from custom branch (with smart contract support)
For a local docker compose setup, a docker-compose.debug-sc.yml file has been provided in the root of this repository. It uses a image hosted in Docker hub built manually from a specific branch. These builds must be considered extremely volatile!
- `HASKELL_RTS_VARIANT` applies to all platforms and is the prefix of the GHC runtime library that should be linked.
This defaults to `libHSrts_thr-` for the threaded version.

For the most simple and common setup, simply run the below command in the root of the checked out repository
```bash
$> NUM_BAKERS=5 DESIRED_PEERS=4 docker-compose -f docker-compose.debug-sc.yml up --scale baker=5 --force-recreate
```
- `HASKELL_GHC_LIBDIR` applies to all platforms and should be the location of
the GHC libraries directory (by GHC libraries we mean the base runtime system
libraries, base haskell libraries, and dependenencies).
If not given the script will try to discover the value by running `stack ghc -- --print-libdir`.

### CAVEATS

- Note that [build.rs](./build.rs) **will not** automatically build the Haskell
dependencies, it will only try to discover them. Building should be done before
by running `stack build` inside
[../concordium-consensus/](../concordium-consensus/) or running

```console
stack --stack-yaml ../concordium-consensus/stack.yaml build
```

Once the node is built it can be run as
```console
cargo run --
```
or
```console
cargo run --release --
```
to be run in release mode for improved performance. Note that the
[concordium-consensus](../concordium-consensus/) dependency is the same regardless of how the
node itself is built, the `--release` only applies to the optimization of the Rust node xcomponents.

For more complicated setups the EXTRA_ARGS environment variable can be set.
- The node built with Haskell library auto-discovery is not suitable for distribution to other
machines. It is a dynamically linked binary with a large number of shared library dependencies
that have

## Middleware local development mode
The PostGreSQL instance is exposed on port 5432/tcp and the username is `concordium`, password: `concordium`, and database name is `concordium`.

### Running the local development version from the stable master branch
Use docker-compose if you only need a middle-ware enabled set of nodes to test on
```bash
$> NUM_BAKERS=5 DESIRED_PEERS=4 docker-compose -f docker-compose.middleware.yml up --scale baker=5 --force-recreate
```

Remember to clean out PostGreSQL data between runs using
```bash
$> NUM_BAKERS=5 DESIRED_PEERS=4 docker-compose -f docker-compose.middleware.yml down
```

### Running the local development version from the unstable develop branch (middleware)
Use docker-compose if you only need a middle-ware enabled set of nodes to test on
```bash
$> NUM_BAKERS=5 DESIRED_PEERS=4 docker-compose -f docker-compose.develop.middleware.yml up --scale baker=5 --force-recreate
```

Remember to clean out PostGreSQL data between runs using
```bash
$> NUM_BAKERS=5 DESIRED_PEERS=4 docker-compose -f docker-compose.develop.middleware.yml down
```

### Delay baker startup if PostGreSQL starts too slowly
If PostGreSQL starts too slowly the baker enabled for logging to it can be delayed by using the variable `DB_SLEEP`


## Wallet local development mode
The PostGreSQL instance is exposed on port 5432/tcp and the username is `concordium`, password: `concordium`, and database name is `concordium`.
The wallet-proxy is mapped on port 14000/tcp.

### Running the local development version from the stable master branch
Use docker-compose if you only need a middle-ware enabled set of nodes to test on
```bash
$> NUM_BAKERS=5 DESIRED_PEERS=4 docker-compose -f docker-compose.wallet-dev.yml up --scale baker=5 --force-recreate
```
## Installing genesis data
Unpack the relevant set of genesis data and private baker data from [genesis-data/](/genesis-data) to the correct OS folder (e.g. on Linux this would be `$HOME/.local/share/concordium`). This determines how many bakers you need to run for the network to be able to work properly.

Remember to clean out PostGreSQL data between runs using
```bash
$> NUM_BAKERS=5 DESIRED_PEERS=4 docker-compose -f docker-compose.wallet-dev.yml down
# Running all tests
```console
$> cargo test --all
```

### Running the local development version from the unstable develop branch
Use docker-compose if you only need a middle-ware enabled set of nodes to test on
```bash
$> NUM_BAKERS=5 DESIRED_PEERS=4 docker-compose -f docker-compose.develop.wallet-dev.yml up --scale baker=5 --force-recreate
# Obtaining documentation
The output is placed in `target/doc` by default.
```console
$> cargo doc
```

Remember to clean out PostGreSQL data between runs using
```bash
$> NUM_BAKERS=5 DESIRED_PEERS=4 docker-compose -f docker-compose.develop.wallet-dev.yml down
To automatically open the browser with the documentation once it is generated to
```console
$> cargo doc --open
```

### Delay baker startup if PostGreSQL starts too slowly
If PostGreSQL starts too slowly the baker enabled for logging to it can be delayed by using the variable `DB_SLEEP` (the wallet-proxy has a default value of 30 set to delay start until PostGreSQL is up).
3 changes: 1 addition & 2 deletions concordium-node/src/bin/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ async fn main() -> Fallible<()> {
// The push gateway to Prometheus thread
start_push_gateway(&conf.prometheus, &node.stats, node.id());

let is_baker =
conf.cli.baker.baker_id.is_some() || conf.cli.baker.baker_credentials_file.is_some();
let is_baker = conf.cli.baker.baker_credentials_file.is_some();

let data_dir_path = app_prefs.get_user_app_dir();
let (gen_data, priv_data) = get_baker_data(&app_prefs, &conf.cli.baker, is_baker)
Expand Down
4 changes: 0 additions & 4 deletions concordium-node/src/bin/genesis_tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ pub fn main() -> Fallible<()> {
u64::max_value(),
genesis_data,
private_data.clone(),
match private_data {
Some(_) => Some(0),
_ => None,
},
ConsensusLogLevel::Info,
&tmp_dir.into_path(),
&"",
Expand Down
2 changes: 0 additions & 2 deletions concordium-node/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ pub struct PrometheusConfig {
#[derive(StructOpt, Debug)]
/// Parameters related to Baking (only used in cli).
pub struct BakerConfig {
#[structopt(long = "baker-id", help = "Baker ID")]
pub baker_id: Option<u64>,
#[cfg(feature = "profiling")]
#[structopt(
long = "heap-profiling",
Expand Down
4 changes: 0 additions & 4 deletions concordium-node/src/consensus_ffi/consensus.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::consensus_ffi::{
blockchain_types::BakerId,
ffi::{consensus_runner, get_consensus_ptr, startBaker, stopBaker, stopConsensus},
helpers::{QueueReceiver, QueueSyncSender, RelayOrStopSenderHelper},
messaging::ConsensusMessage,
Expand Down Expand Up @@ -215,7 +214,6 @@ pub struct ConsensusContainer {
pub max_block_size: u64,
pub insertions_before_purging: u64,
pub transaction_keep_alive: u64,
pub baker_id: Option<BakerId>,
pub is_baking: Arc<AtomicBool>,
pub consensus: Arc<AtomicPtr<consensus_runner>>,
pub genesis: Arc<[u8]>,
Expand All @@ -233,7 +231,6 @@ impl ConsensusContainer {
transactions_purging_delay: u64,
genesis_data: Vec<u8>,
private_data: Option<Vec<u8>>,
baker_id: Option<BakerId>,
max_log_level: ConsensusLogLevel,
appdata_dir: &PathBuf,
database_connection_url: &str,
Expand Down Expand Up @@ -261,7 +258,6 @@ impl ConsensusContainer {
max_block_size,
insertions_before_purging,
transaction_keep_alive,
baker_id,
is_baking: Arc::new(AtomicBool::new(false)),
consensus: Arc::new(AtomicPtr::new(consensus_ptr)),
genesis: Arc::from(genesis_data),
Expand Down
14 changes: 2 additions & 12 deletions concordium-node/src/plugins/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ use std::{
};

const FILE_NAME_GENESIS_DATA: &str = "genesis.dat";
const FILE_NAME_PREFIX_BAKER_PRIVATE: &str = "baker-";
const FILE_NAME_SUFFIX_BAKER_PRIVATE: &str = "-credentials.json";

/// Initializes the consensus layer with the given setup.
pub fn start_consensus_layer(
Expand Down Expand Up @@ -70,7 +68,6 @@ pub fn start_consensus_layer(
u64::from(conf.transactions_purging_delay),
genesis_data,
private_data,
conf.baker_id,
max_logging_level,
appdata_dir,
database_connection_url,
Expand All @@ -95,14 +92,7 @@ pub fn get_baker_data(
let credentials_loc = if let Some(path) = &conf.baker_credentials_file {
std::path::PathBuf::from(path)
} else {
let mut private_loc = app_prefs.get_user_app_dir();
if let Some(baker_id) = conf.baker_id {
private_loc.push(format!(
"{}{}{}",
FILE_NAME_PREFIX_BAKER_PRIVATE, baker_id, FILE_NAME_SUFFIX_BAKER_PRIVATE
));
}
private_loc
bail!("Baker credentials file not supplied.")
};

let genesis_data = match OpenOptions::new().read(true).open(&genesis_loc) {
Expand All @@ -125,7 +115,7 @@ pub fn get_baker_data(
Err(_) => bail!("Couldn't open up private baker file for reading"),
}
}
Err(e) => bail!("Can't open the private data file ({})!", e),
Err(e) => bail!("Can't open the baker credentials file ({})!", e),
}
} else {
None
Expand Down
Loading

0 comments on commit be406fb

Please sign in to comment.