2019-08-23 06:39:32 +00:00
|
|
|
mod config;
|
2019-02-27 23:24:27 +00:00
|
|
|
mod run;
|
2019-02-14 01:09:18 +00:00
|
|
|
|
2019-08-23 06:39:32 +00:00
|
|
|
use clap::{App, Arg, SubCommand};
|
|
|
|
use config::get_configs;
|
2019-04-15 03:58:41 +00:00
|
|
|
use env_logger::{Builder, Env};
|
2019-08-10 01:44:17 +00:00
|
|
|
use slog::{crit, o, warn, Drain, Level};
|
2019-06-08 01:00:34 +00:00
|
|
|
|
|
|
|
pub const DEFAULT_DATA_DIR: &str = ".lighthouse";
|
2019-06-09 10:41:51 +00:00
|
|
|
pub const CLIENT_CONFIG_FILENAME: &str = "beacon-node.toml";
|
2019-06-09 10:35:36 +00:00
|
|
|
pub const ETH2_CONFIG_FILENAME: &str = "eth2-spec.toml";
|
2019-08-06 03:29:27 +00:00
|
|
|
pub const TESTNET_CONFIG_FILENAME: &str = "testnet.toml";
|
2019-06-08 17:17:03 +00:00
|
|
|
|
2019-02-14 01:09:18 +00:00
|
|
|
fn main() {
|
2019-04-15 03:58:41 +00:00
|
|
|
// debugging output for libp2p and external crates
|
|
|
|
Builder::from_env(Env::default()).init();
|
|
|
|
|
2019-02-14 01:09:18 +00:00
|
|
|
let matches = App::new("Lighthouse")
|
2019-02-27 23:24:27 +00:00
|
|
|
.version(version::version().as_str())
|
|
|
|
.author("Sigma Prime <contact@sigmaprime.io>")
|
2019-02-14 01:09:18 +00:00
|
|
|
.about("Eth 2.0 Client")
|
2019-08-06 03:29:27 +00:00
|
|
|
/*
|
|
|
|
* Configuration directory locations.
|
|
|
|
*/
|
2019-02-14 01:09:18 +00:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("datadir")
|
|
|
|
.long("datadir")
|
|
|
|
.value_name("DIR")
|
|
|
|
.help("Data directory for keys and databases.")
|
2019-06-08 01:00:34 +00:00
|
|
|
.takes_value(true)
|
2019-08-23 06:39:32 +00:00
|
|
|
.global(true)
|
2019-02-14 01:09:18 +00:00
|
|
|
)
|
2019-07-10 00:27:44 +00:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("logfile")
|
|
|
|
.long("logfile")
|
2019-09-02 14:34:41 +00:00
|
|
|
.value_name("FILE")
|
2019-07-10 00:27:44 +00:00
|
|
|
.help("File path where output will be written.")
|
|
|
|
.takes_value(true),
|
|
|
|
)
|
2019-07-29 03:45:45 +00:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("network-dir")
|
|
|
|
.long("network-dir")
|
2019-09-02 14:34:41 +00:00
|
|
|
.value_name("DIR")
|
2019-07-29 03:45:45 +00:00
|
|
|
.help("Data directory for network keys.")
|
|
|
|
.takes_value(true)
|
2019-08-23 06:39:32 +00:00
|
|
|
.global(true)
|
2019-07-29 03:45:45 +00:00
|
|
|
)
|
2019-08-06 03:29:27 +00:00
|
|
|
/*
|
|
|
|
* Network parameters.
|
|
|
|
*/
|
2019-08-31 02:34:27 +00:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("port-bump")
|
|
|
|
.long("port-bump")
|
|
|
|
.short("b")
|
|
|
|
.value_name("INCREMENT")
|
|
|
|
.help("Sets all listening TCP/UDP ports to default values, but with each port increased by \
|
|
|
|
INCREMENT. Useful when starting multiple nodes on a single machine. Using increments \
|
|
|
|
in multiples of 10 is recommended.")
|
|
|
|
.takes_value(true),
|
|
|
|
)
|
2019-02-27 23:24:27 +00:00
|
|
|
.arg(
|
2019-04-01 05:29:11 +00:00
|
|
|
Arg::with_name("listen-address")
|
2019-03-19 22:58:31 +00:00
|
|
|
.long("listen-address")
|
2019-08-10 01:44:17 +00:00
|
|
|
.value_name("ADDRESS")
|
2019-06-25 08:02:11 +00:00
|
|
|
.help("The address lighthouse will listen for UDP and TCP connections. (default 127.0.0.1).")
|
2019-08-31 02:34:27 +00:00
|
|
|
.takes_value(true)
|
2019-02-14 01:09:18 +00:00
|
|
|
)
|
2019-08-10 01:44:17 +00:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("port")
|
|
|
|
.long("port")
|
|
|
|
.value_name("PORT")
|
|
|
|
.help("The TCP/UDP port to listen on. The UDP port can be modified by the --discovery-port flag.")
|
2019-08-31 02:34:27 +00:00
|
|
|
.conflicts_with("port-bump")
|
2019-08-10 01:44:17 +00:00
|
|
|
.takes_value(true),
|
|
|
|
)
|
2019-06-25 04:51:45 +00:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("maxpeers")
|
|
|
|
.long("maxpeers")
|
2019-06-25 08:02:11 +00:00
|
|
|
.help("The maximum number of peers (default 10).")
|
2019-06-25 04:51:45 +00:00
|
|
|
.takes_value(true),
|
|
|
|
)
|
2019-04-01 01:14:44 +00:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("boot-nodes")
|
|
|
|
.long("boot-nodes")
|
2019-06-25 04:51:45 +00:00
|
|
|
.allow_hyphen_values(true)
|
2019-09-02 14:34:41 +00:00
|
|
|
.value_name("ENR-LIST")
|
2019-06-25 04:51:45 +00:00
|
|
|
.help("One or more comma-delimited base64-encoded ENR's to bootstrap the p2p network.")
|
|
|
|
.takes_value(true),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("discovery-port")
|
|
|
|
.long("disc-port")
|
2019-08-10 01:44:17 +00:00
|
|
|
.value_name("PORT")
|
2019-06-25 08:02:11 +00:00
|
|
|
.help("The discovery UDP port.")
|
2019-08-31 02:34:27 +00:00
|
|
|
.conflicts_with("port-bump")
|
2019-06-25 08:02:11 +00:00
|
|
|
.takes_value(true),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("discovery-address")
|
|
|
|
.long("discovery-address")
|
2019-08-10 01:44:17 +00:00
|
|
|
.value_name("ADDRESS")
|
2019-07-01 06:38:42 +00:00
|
|
|
.help("The IP address to broadcast to other peers on how to reach this node.")
|
2019-04-01 01:14:44 +00:00
|
|
|
.takes_value(true),
|
|
|
|
)
|
2019-08-10 01:44:17 +00:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("topics")
|
|
|
|
.long("topics")
|
|
|
|
.value_name("STRING")
|
|
|
|
.help("One or more comma-delimited gossipsub topic strings to subscribe to.")
|
|
|
|
.takes_value(true),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("libp2p-addresses")
|
|
|
|
.long("libp2p-addresses")
|
|
|
|
.value_name("MULTIADDR")
|
|
|
|
.help("One or more comma-delimited multiaddrs to manually connect to a libp2p peer without an ENR.")
|
|
|
|
.takes_value(true),
|
|
|
|
)
|
2019-08-06 03:29:27 +00:00
|
|
|
/*
|
|
|
|
* gRPC parameters.
|
|
|
|
*/
|
2019-03-19 13:01:00 +00:00
|
|
|
.arg(
|
2019-09-01 09:33:21 +00:00
|
|
|
Arg::with_name("no-grpc")
|
|
|
|
.long("no-grpc")
|
|
|
|
.help("Disable the gRPC server.")
|
2019-03-19 13:01:00 +00:00
|
|
|
.takes_value(false),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("rpc-address")
|
2019-03-19 22:58:31 +00:00
|
|
|
.long("rpc-address")
|
2019-09-02 14:34:41 +00:00
|
|
|
.value_name("ADDRESS")
|
2019-03-19 13:01:00 +00:00
|
|
|
.help("Listen address for RPC endpoint.")
|
|
|
|
.takes_value(true),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("rpc-port")
|
2019-03-19 22:58:31 +00:00
|
|
|
.long("rpc-port")
|
2019-09-02 14:34:41 +00:00
|
|
|
.value_name("PORT")
|
2019-03-19 13:01:00 +00:00
|
|
|
.help("Listen port for RPC endpoint.")
|
2019-08-31 02:34:27 +00:00
|
|
|
.conflicts_with("port-bump")
|
2019-03-19 13:01:00 +00:00
|
|
|
.takes_value(true),
|
|
|
|
)
|
2019-08-10 01:44:17 +00:00
|
|
|
/* Client related arguments */
|
First RESTful HTTP API (#399)
* Added generated code for REST API.
- Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
- Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
* Removed openapi generated code, because it was the rust client, not the rust server.
* Added the correct rust-server code, automatically generated from openapi.
* Added generated code for REST API.
- Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
- Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
* Removed openapi generated code, because it was the rust client, not the rust server.
* Added the correct rust-server code, automatically generated from openapi.
* Included REST API in configuratuion.
- Started adding the rest_api into the beacon node's dependencies.
- Set up configuration file for rest_api and integrated into main client config
- Added CLI flags for REST API.
* Futher work on REST API.
- Adding the dependencies to rest_api crate
- Created a skeleton BeaconNodeService, which will handle /node requests.
- Started the rest_api server definition, with the high level request handling logic.
* Added generated code for REST API.
- Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
- Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
* Removed openapi generated code, because it was the rust client, not the rust server.
* Added the correct rust-server code, automatically generated from openapi.
* Included REST API in configuratuion.
- Started adding the rest_api into the beacon node's dependencies.
- Set up configuration file for rest_api and integrated into main client config
- Added CLI flags for REST API.
* Futher work on REST API.
- Adding the dependencies to rest_api crate
- Created a skeleton BeaconNodeService, which will handle /node requests.
- Started the rest_api server definition, with the high level request handling logic.
* WIP: Restructured REST API to use hyper_router and separate services.
* WIP: Fixing rust for REST API
* WIP: Fixed up many bugs in trying to get router to compile.
* WIP: Got the beacon_node to compile with the REST changes
* Basic API works!
- Changed CLI flags from rest-api* to api*
- Fixed port cli flag
- Tested, works over HTTP
* WIP: Moved things around so that we can get state inside the handlers.
* WIP: Significant API updates.
- Started writing a macro for getting the handler functions.
- Added the BeaconChain into the type map, gives stateful access to the beacon state.
- Created new generic error types (haven't figured out yet), to reduce code duplication.
- Moved common stuff into lib.rs
* WIP: Factored macros, defined API result and error.
- did more logging when creating HTTP responses
- Tried moving stuff into macros, but can't get macros in macros to compile.
- Pulled out a lot of placeholder code.
* Fixed macros so that things compile.
* Cleaned up code.
- Removed unused imports
- Removed comments
- Addressed all compiler warnings.
- Ran cargo fmt.
* Removed auto-generated OpenAPI code.
* Addressed Paul's suggestions.
- Fixed spelling mistake
- Moved the simple macros into functions, since it doesn't make sense for them to be macros.
- Removed redundant code & inclusions.
* Removed redundant validate_request function.
* Included graceful shutdown in Hyper server.
* Fixing the dropped exit_signal, which prevented the API from starting.
* Wrapped the exit signal, to get an API shutdown log line.
2019-07-31 08:29:41 +00:00
|
|
|
.arg(
|
2019-09-01 09:33:21 +00:00
|
|
|
Arg::with_name("no-api")
|
|
|
|
.long("no-api")
|
|
|
|
.help("Disable RESTful HTTP API server.")
|
First RESTful HTTP API (#399)
* Added generated code for REST API.
- Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
- Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
* Removed openapi generated code, because it was the rust client, not the rust server.
* Added the correct rust-server code, automatically generated from openapi.
* Added generated code for REST API.
- Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
- Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
* Removed openapi generated code, because it was the rust client, not the rust server.
* Added the correct rust-server code, automatically generated from openapi.
* Included REST API in configuratuion.
- Started adding the rest_api into the beacon node's dependencies.
- Set up configuration file for rest_api and integrated into main client config
- Added CLI flags for REST API.
* Futher work on REST API.
- Adding the dependencies to rest_api crate
- Created a skeleton BeaconNodeService, which will handle /node requests.
- Started the rest_api server definition, with the high level request handling logic.
* Added generated code for REST API.
- Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
- Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
* Removed openapi generated code, because it was the rust client, not the rust server.
* Added the correct rust-server code, automatically generated from openapi.
* Included REST API in configuratuion.
- Started adding the rest_api into the beacon node's dependencies.
- Set up configuration file for rest_api and integrated into main client config
- Added CLI flags for REST API.
* Futher work on REST API.
- Adding the dependencies to rest_api crate
- Created a skeleton BeaconNodeService, which will handle /node requests.
- Started the rest_api server definition, with the high level request handling logic.
* WIP: Restructured REST API to use hyper_router and separate services.
* WIP: Fixing rust for REST API
* WIP: Fixed up many bugs in trying to get router to compile.
* WIP: Got the beacon_node to compile with the REST changes
* Basic API works!
- Changed CLI flags from rest-api* to api*
- Fixed port cli flag
- Tested, works over HTTP
* WIP: Moved things around so that we can get state inside the handlers.
* WIP: Significant API updates.
- Started writing a macro for getting the handler functions.
- Added the BeaconChain into the type map, gives stateful access to the beacon state.
- Created new generic error types (haven't figured out yet), to reduce code duplication.
- Moved common stuff into lib.rs
* WIP: Factored macros, defined API result and error.
- did more logging when creating HTTP responses
- Tried moving stuff into macros, but can't get macros in macros to compile.
- Pulled out a lot of placeholder code.
* Fixed macros so that things compile.
* Cleaned up code.
- Removed unused imports
- Removed comments
- Addressed all compiler warnings.
- Ran cargo fmt.
* Removed auto-generated OpenAPI code.
* Addressed Paul's suggestions.
- Fixed spelling mistake
- Moved the simple macros into functions, since it doesn't make sense for them to be macros.
- Removed redundant code & inclusions.
* Removed redundant validate_request function.
* Included graceful shutdown in Hyper server.
* Fixing the dropped exit_signal, which prevented the API from starting.
* Wrapped the exit signal, to get an API shutdown log line.
2019-07-31 08:29:41 +00:00
|
|
|
.takes_value(false),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("api-address")
|
|
|
|
.long("api-address")
|
2019-09-02 14:34:41 +00:00
|
|
|
.value_name("ADDRESS")
|
First RESTful HTTP API (#399)
* Added generated code for REST API.
- Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
- Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
* Removed openapi generated code, because it was the rust client, not the rust server.
* Added the correct rust-server code, automatically generated from openapi.
* Added generated code for REST API.
- Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
- Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
* Removed openapi generated code, because it was the rust client, not the rust server.
* Added the correct rust-server code, automatically generated from openapi.
* Included REST API in configuratuion.
- Started adding the rest_api into the beacon node's dependencies.
- Set up configuration file for rest_api and integrated into main client config
- Added CLI flags for REST API.
* Futher work on REST API.
- Adding the dependencies to rest_api crate
- Created a skeleton BeaconNodeService, which will handle /node requests.
- Started the rest_api server definition, with the high level request handling logic.
* Added generated code for REST API.
- Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
- Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
* Removed openapi generated code, because it was the rust client, not the rust server.
* Added the correct rust-server code, automatically generated from openapi.
* Included REST API in configuratuion.
- Started adding the rest_api into the beacon node's dependencies.
- Set up configuration file for rest_api and integrated into main client config
- Added CLI flags for REST API.
* Futher work on REST API.
- Adding the dependencies to rest_api crate
- Created a skeleton BeaconNodeService, which will handle /node requests.
- Started the rest_api server definition, with the high level request handling logic.
* WIP: Restructured REST API to use hyper_router and separate services.
* WIP: Fixing rust for REST API
* WIP: Fixed up many bugs in trying to get router to compile.
* WIP: Got the beacon_node to compile with the REST changes
* Basic API works!
- Changed CLI flags from rest-api* to api*
- Fixed port cli flag
- Tested, works over HTTP
* WIP: Moved things around so that we can get state inside the handlers.
* WIP: Significant API updates.
- Started writing a macro for getting the handler functions.
- Added the BeaconChain into the type map, gives stateful access to the beacon state.
- Created new generic error types (haven't figured out yet), to reduce code duplication.
- Moved common stuff into lib.rs
* WIP: Factored macros, defined API result and error.
- did more logging when creating HTTP responses
- Tried moving stuff into macros, but can't get macros in macros to compile.
- Pulled out a lot of placeholder code.
* Fixed macros so that things compile.
* Cleaned up code.
- Removed unused imports
- Removed comments
- Addressed all compiler warnings.
- Ran cargo fmt.
* Removed auto-generated OpenAPI code.
* Addressed Paul's suggestions.
- Fixed spelling mistake
- Moved the simple macros into functions, since it doesn't make sense for them to be macros.
- Removed redundant code & inclusions.
* Removed redundant validate_request function.
* Included graceful shutdown in Hyper server.
* Fixing the dropped exit_signal, which prevented the API from starting.
* Wrapped the exit signal, to get an API shutdown log line.
2019-07-31 08:29:41 +00:00
|
|
|
.help("Set the listen address for the RESTful HTTP API server.")
|
|
|
|
.takes_value(true),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("api-port")
|
|
|
|
.long("api-port")
|
2019-09-02 14:34:41 +00:00
|
|
|
.value_name("PORT")
|
First RESTful HTTP API (#399)
* Added generated code for REST API.
- Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
- Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
* Removed openapi generated code, because it was the rust client, not the rust server.
* Added the correct rust-server code, automatically generated from openapi.
* Added generated code for REST API.
- Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
- Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
* Removed openapi generated code, because it was the rust client, not the rust server.
* Added the correct rust-server code, automatically generated from openapi.
* Included REST API in configuratuion.
- Started adding the rest_api into the beacon node's dependencies.
- Set up configuration file for rest_api and integrated into main client config
- Added CLI flags for REST API.
* Futher work on REST API.
- Adding the dependencies to rest_api crate
- Created a skeleton BeaconNodeService, which will handle /node requests.
- Started the rest_api server definition, with the high level request handling logic.
* Added generated code for REST API.
- Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
- Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
* Removed openapi generated code, because it was the rust client, not the rust server.
* Added the correct rust-server code, automatically generated from openapi.
* Included REST API in configuratuion.
- Started adding the rest_api into the beacon node's dependencies.
- Set up configuration file for rest_api and integrated into main client config
- Added CLI flags for REST API.
* Futher work on REST API.
- Adding the dependencies to rest_api crate
- Created a skeleton BeaconNodeService, which will handle /node requests.
- Started the rest_api server definition, with the high level request handling logic.
* WIP: Restructured REST API to use hyper_router and separate services.
* WIP: Fixing rust for REST API
* WIP: Fixed up many bugs in trying to get router to compile.
* WIP: Got the beacon_node to compile with the REST changes
* Basic API works!
- Changed CLI flags from rest-api* to api*
- Fixed port cli flag
- Tested, works over HTTP
* WIP: Moved things around so that we can get state inside the handlers.
* WIP: Significant API updates.
- Started writing a macro for getting the handler functions.
- Added the BeaconChain into the type map, gives stateful access to the beacon state.
- Created new generic error types (haven't figured out yet), to reduce code duplication.
- Moved common stuff into lib.rs
* WIP: Factored macros, defined API result and error.
- did more logging when creating HTTP responses
- Tried moving stuff into macros, but can't get macros in macros to compile.
- Pulled out a lot of placeholder code.
* Fixed macros so that things compile.
* Cleaned up code.
- Removed unused imports
- Removed comments
- Addressed all compiler warnings.
- Ran cargo fmt.
* Removed auto-generated OpenAPI code.
* Addressed Paul's suggestions.
- Fixed spelling mistake
- Moved the simple macros into functions, since it doesn't make sense for them to be macros.
- Removed redundant code & inclusions.
* Removed redundant validate_request function.
* Included graceful shutdown in Hyper server.
* Fixing the dropped exit_signal, which prevented the API from starting.
* Wrapped the exit signal, to get an API shutdown log line.
2019-07-31 08:29:41 +00:00
|
|
|
.help("Set the listen TCP port for the RESTful HTTP API server.")
|
2019-08-31 02:34:27 +00:00
|
|
|
.conflicts_with("port-bump")
|
First RESTful HTTP API (#399)
* Added generated code for REST API.
- Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
- Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
* Removed openapi generated code, because it was the rust client, not the rust server.
* Added the correct rust-server code, automatically generated from openapi.
* Added generated code for REST API.
- Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
- Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
* Removed openapi generated code, because it was the rust client, not the rust server.
* Added the correct rust-server code, automatically generated from openapi.
* Included REST API in configuratuion.
- Started adding the rest_api into the beacon node's dependencies.
- Set up configuration file for rest_api and integrated into main client config
- Added CLI flags for REST API.
* Futher work on REST API.
- Adding the dependencies to rest_api crate
- Created a skeleton BeaconNodeService, which will handle /node requests.
- Started the rest_api server definition, with the high level request handling logic.
* Added generated code for REST API.
- Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
- Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
* Removed openapi generated code, because it was the rust client, not the rust server.
* Added the correct rust-server code, automatically generated from openapi.
* Included REST API in configuratuion.
- Started adding the rest_api into the beacon node's dependencies.
- Set up configuration file for rest_api and integrated into main client config
- Added CLI flags for REST API.
* Futher work on REST API.
- Adding the dependencies to rest_api crate
- Created a skeleton BeaconNodeService, which will handle /node requests.
- Started the rest_api server definition, with the high level request handling logic.
* WIP: Restructured REST API to use hyper_router and separate services.
* WIP: Fixing rust for REST API
* WIP: Fixed up many bugs in trying to get router to compile.
* WIP: Got the beacon_node to compile with the REST changes
* Basic API works!
- Changed CLI flags from rest-api* to api*
- Fixed port cli flag
- Tested, works over HTTP
* WIP: Moved things around so that we can get state inside the handlers.
* WIP: Significant API updates.
- Started writing a macro for getting the handler functions.
- Added the BeaconChain into the type map, gives stateful access to the beacon state.
- Created new generic error types (haven't figured out yet), to reduce code duplication.
- Moved common stuff into lib.rs
* WIP: Factored macros, defined API result and error.
- did more logging when creating HTTP responses
- Tried moving stuff into macros, but can't get macros in macros to compile.
- Pulled out a lot of placeholder code.
* Fixed macros so that things compile.
* Cleaned up code.
- Removed unused imports
- Removed comments
- Addressed all compiler warnings.
- Ran cargo fmt.
* Removed auto-generated OpenAPI code.
* Addressed Paul's suggestions.
- Fixed spelling mistake
- Moved the simple macros into functions, since it doesn't make sense for them to be macros.
- Removed redundant code & inclusions.
* Removed redundant validate_request function.
* Included graceful shutdown in Hyper server.
* Fixing the dropped exit_signal, which prevented the API from starting.
* Wrapped the exit signal, to get an API shutdown log line.
2019-07-31 08:29:41 +00:00
|
|
|
.takes_value(true),
|
|
|
|
)
|
2019-08-06 03:29:27 +00:00
|
|
|
|
2019-09-03 06:40:53 +00:00
|
|
|
/*
|
|
|
|
* Eth1 Integration
|
|
|
|
*/
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("eth1-server")
|
|
|
|
.long("eth1-server")
|
|
|
|
.value_name("SERVER")
|
|
|
|
.help("Specifies the server for a web3 connection to the Eth1 chain.")
|
|
|
|
.takes_value(true)
|
|
|
|
)
|
2019-08-06 03:29:27 +00:00
|
|
|
/*
|
|
|
|
* Database parameters.
|
|
|
|
*/
|
2019-03-31 07:57:48 +00:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("db")
|
|
|
|
.long("db")
|
|
|
|
.value_name("DB")
|
|
|
|
.help("Type of database to use.")
|
|
|
|
.takes_value(true)
|
2019-05-21 07:45:35 +00:00
|
|
|
.possible_values(&["disk", "memory"])
|
2019-08-25 02:14:04 +00:00
|
|
|
.default_value("disk"),
|
2019-03-31 07:57:48 +00:00
|
|
|
)
|
2019-08-06 03:29:27 +00:00
|
|
|
/*
|
|
|
|
* Logging.
|
|
|
|
*/
|
2019-07-29 03:45:45 +00:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("debug-level")
|
|
|
|
.long("debug-level")
|
|
|
|
.value_name("LEVEL")
|
|
|
|
.help("The title of the spec constants for chain config.")
|
|
|
|
.takes_value(true)
|
|
|
|
.possible_values(&["info", "debug", "trace", "warn", "error", "crit"])
|
2019-08-10 01:44:17 +00:00
|
|
|
.default_value("trace"),
|
2019-07-29 03:45:45 +00:00
|
|
|
)
|
2019-08-15 02:48:34 +00:00
|
|
|
/*
|
2019-08-23 06:39:32 +00:00
|
|
|
* The "testnet" sub-command.
|
|
|
|
*
|
|
|
|
* Allows for creating a new datadir with testnet-specific configs.
|
2019-08-15 02:48:34 +00:00
|
|
|
*/
|
2019-08-23 06:39:32 +00:00
|
|
|
.subcommand(SubCommand::with_name("testnet")
|
|
|
|
.about("Create a new Lighthouse datadir using a testnet strategy.")
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("spec")
|
|
|
|
.short("s")
|
|
|
|
.long("spec")
|
|
|
|
.value_name("TITLE")
|
|
|
|
.help("Specifies the default eth2 spec type. Only effective when creating a new datadir.")
|
|
|
|
.takes_value(true)
|
|
|
|
.required(true)
|
|
|
|
.possible_values(&["mainnet", "minimal", "interop"])
|
2019-08-26 05:47:03 +00:00
|
|
|
.default_value("minimal")
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("eth2-config")
|
|
|
|
.long("eth2-config")
|
|
|
|
.value_name("TOML_FILE")
|
|
|
|
.help("A existing eth2_spec TOML file (e.g., eth2_spec.toml).")
|
|
|
|
.takes_value(true)
|
|
|
|
.conflicts_with("spec")
|
|
|
|
)
|
|
|
|
.arg(
|
2019-08-26 05:51:11 +00:00
|
|
|
Arg::with_name("client-config")
|
|
|
|
.long("client-config")
|
2019-08-26 05:47:03 +00:00
|
|
|
.value_name("TOML_FILE")
|
|
|
|
.help("An existing beacon_node TOML file (e.g., beacon_node.toml).")
|
|
|
|
.takes_value(true)
|
2019-08-23 06:39:32 +00:00
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("random-datadir")
|
|
|
|
.long("random-datadir")
|
|
|
|
.short("r")
|
|
|
|
.help("If present, append a random string to the datadir path. Useful for fast development \
|
|
|
|
iteration.")
|
|
|
|
)
|
|
|
|
.arg(
|
2019-08-25 02:14:04 +00:00
|
|
|
Arg::with_name("force")
|
|
|
|
.long("force")
|
2019-08-23 06:39:32 +00:00
|
|
|
.short("f")
|
2019-08-26 05:47:03 +00:00
|
|
|
.help("If present, will create new config and database files and move the any existing to a \
|
|
|
|
backup directory.")
|
2019-08-23 06:39:32 +00:00
|
|
|
.conflicts_with("random-datadir")
|
|
|
|
)
|
2019-09-02 00:22:29 +00:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("slot-time")
|
|
|
|
.long("slot-time")
|
|
|
|
.short("t")
|
|
|
|
.value_name("MILLISECONDS")
|
|
|
|
.help("Defines the slot time when creating a new testnet.")
|
|
|
|
)
|
2019-08-23 06:39:32 +00:00
|
|
|
/*
|
2019-08-25 02:14:04 +00:00
|
|
|
* `boostrap`
|
|
|
|
*
|
|
|
|
* Start a new node by downloading genesis and network info from another node via the
|
|
|
|
* HTTP API.
|
2019-08-23 06:39:32 +00:00
|
|
|
*/
|
|
|
|
.subcommand(SubCommand::with_name("bootstrap")
|
|
|
|
.about("Connects to the given HTTP server, downloads a genesis state and attempts to peer with it.")
|
|
|
|
.arg(Arg::with_name("server")
|
|
|
|
.value_name("HTTP_SERVER")
|
|
|
|
.required(true)
|
2019-09-01 23:59:52 +00:00
|
|
|
.default_value("http://localhost:5052")
|
2019-08-23 06:39:32 +00:00
|
|
|
.help("A HTTP server, with a http:// prefix"))
|
|
|
|
.arg(Arg::with_name("libp2p-port")
|
|
|
|
.short("p")
|
|
|
|
.long("port")
|
|
|
|
.value_name("TCP_PORT")
|
2019-08-24 23:43:03 +00:00
|
|
|
.help("A libp2p listen port used to peer with the bootstrap server. This flag is useful \
|
|
|
|
when port-fowarding is used: you may connect using a different port than \
|
|
|
|
the one the server is immediately listening on."))
|
2019-08-23 06:39:32 +00:00
|
|
|
)
|
2019-08-25 02:14:04 +00:00
|
|
|
/*
|
|
|
|
* `recent`
|
|
|
|
*
|
|
|
|
* Start a new node, with a specified number of validators with a genesis time in the last
|
|
|
|
* 30-minutes.
|
|
|
|
*/
|
2019-08-23 06:39:32 +00:00
|
|
|
.subcommand(SubCommand::with_name("recent")
|
|
|
|
.about("Creates a new genesis state where the genesis time was at the previous \
|
2019-08-29 04:59:32 +00:00
|
|
|
MINUTES boundary (e.g., when MINUTES == 30; 12:00, 12:30, 13:00, etc.)")
|
2019-08-23 06:39:32 +00:00
|
|
|
.arg(Arg::with_name("validator_count")
|
|
|
|
.value_name("VALIDATOR_COUNT")
|
|
|
|
.required(true)
|
|
|
|
.help("The number of validators in the genesis state"))
|
2019-08-29 04:59:32 +00:00
|
|
|
.arg(Arg::with_name("minutes")
|
2019-08-29 05:03:52 +00:00
|
|
|
.long("minutes")
|
2019-08-29 04:59:32 +00:00
|
|
|
.short("m")
|
|
|
|
.value_name("MINUTES")
|
|
|
|
.required(true)
|
|
|
|
.default_value("15")
|
|
|
|
.help("The maximum number of minutes that will have elapsed before genesis"))
|
2019-08-23 06:39:32 +00:00
|
|
|
)
|
2019-08-31 02:34:27 +00:00
|
|
|
/*
|
|
|
|
* `quick`
|
|
|
|
*
|
|
|
|
* Start a new node, specifying the number of validators and genesis time
|
|
|
|
*/
|
|
|
|
.subcommand(SubCommand::with_name("quick")
|
|
|
|
.about("Creates a new genesis state from the specified validator count and genesis time. \
|
|
|
|
Compatible with the `quick-start genesis` defined in the eth2.0-pm repo.")
|
|
|
|
.arg(Arg::with_name("validator_count")
|
|
|
|
.value_name("VALIDATOR_COUNT")
|
|
|
|
.required(true)
|
|
|
|
.help("The number of validators in the genesis state"))
|
|
|
|
.arg(Arg::with_name("genesis_time")
|
|
|
|
.value_name("UNIX_EPOCH_SECONDS")
|
|
|
|
.required(true)
|
|
|
|
.help("The genesis time for the given state."))
|
|
|
|
)
|
|
|
|
/*
|
|
|
|
* `yaml`
|
|
|
|
*
|
|
|
|
* Start a new node, using a genesis state loaded from a YAML file
|
|
|
|
*/
|
2019-09-02 05:07:48 +00:00
|
|
|
.subcommand(SubCommand::with_name("file")
|
|
|
|
.about("Creates a new datadir where the genesis state is read from YAML. May fail to parse \
|
|
|
|
a file that was generated to a different spec than that specified by --spec.")
|
|
|
|
.arg(Arg::with_name("format")
|
|
|
|
.value_name("FORMAT")
|
|
|
|
.required(true)
|
2019-09-02 05:58:53 +00:00
|
|
|
.possible_values(&["yaml", "ssz", "json"])
|
2019-09-02 05:07:48 +00:00
|
|
|
.help("The encoding of the state in the file."))
|
2019-08-23 06:39:32 +00:00
|
|
|
.arg(Arg::with_name("file")
|
|
|
|
.value_name("YAML_FILE")
|
|
|
|
.required(true)
|
|
|
|
.help("A YAML file from which to read the state"))
|
|
|
|
)
|
2019-08-15 02:48:34 +00:00
|
|
|
)
|
2019-02-14 01:09:18 +00:00
|
|
|
.get_matches();
|
|
|
|
|
2019-04-15 01:29:08 +00:00
|
|
|
// build the initial logger
|
|
|
|
let decorator = slog_term::TermDecorator::new().build();
|
2019-07-30 23:06:53 +00:00
|
|
|
let decorator = logging::AlignedTermDecorator::new(decorator, logging::MAX_MESSAGE_WIDTH);
|
2019-07-29 03:45:45 +00:00
|
|
|
let drain = slog_term::FullFormat::new(decorator).build().fuse();
|
2019-04-15 01:29:08 +00:00
|
|
|
let drain = slog_async::Async::new(drain).build();
|
|
|
|
|
2019-07-29 03:45:45 +00:00
|
|
|
let drain = match matches.value_of("debug-level") {
|
|
|
|
Some("info") => drain.filter_level(Level::Info),
|
|
|
|
Some("debug") => drain.filter_level(Level::Debug),
|
|
|
|
Some("trace") => drain.filter_level(Level::Trace),
|
|
|
|
Some("warn") => drain.filter_level(Level::Warning),
|
|
|
|
Some("error") => drain.filter_level(Level::Error),
|
|
|
|
Some("crit") => drain.filter_level(Level::Critical),
|
|
|
|
_ => unreachable!("guarded by clap"),
|
|
|
|
};
|
|
|
|
|
2019-08-23 06:39:32 +00:00
|
|
|
let log = slog::Logger::root(drain.fuse(), o!());
|
2019-04-15 01:29:08 +00:00
|
|
|
|
2019-08-15 08:48:39 +00:00
|
|
|
warn!(
|
|
|
|
log,
|
|
|
|
"Ethereum 2.0 is pre-release. This software is experimental."
|
|
|
|
);
|
|
|
|
|
2019-08-23 06:39:32 +00:00
|
|
|
// Load the process-wide configuration.
|
2019-06-09 00:21:50 +00:00
|
|
|
//
|
2019-08-23 06:39:32 +00:00
|
|
|
// May load this from disk or create a new configuration, depending on the CLI flags supplied.
|
|
|
|
let (client_config, eth2_config) = match get_configs(&matches, &log) {
|
|
|
|
Ok(configs) => configs,
|
2019-06-08 17:17:03 +00:00
|
|
|
Err(e) => {
|
2019-08-23 06:39:32 +00:00
|
|
|
crit!(log, "Failed to load configuration"; "error" => e);
|
2019-06-07 23:44:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
};
|
2019-02-14 01:09:18 +00:00
|
|
|
|
2019-07-29 03:45:45 +00:00
|
|
|
// Start the node using a `tokio` executor.
|
2019-07-01 06:38:42 +00:00
|
|
|
match run::run_beacon_node(client_config, eth2_config, &log) {
|
2019-03-19 11:53:51 +00:00
|
|
|
Ok(_) => {}
|
2019-07-01 06:38:42 +00:00
|
|
|
Err(e) => crit!(log, "Beacon node failed to start"; "reason" => format!("{:}", e)),
|
2019-03-19 11:53:51 +00:00
|
|
|
}
|
2019-02-14 01:09:18 +00:00
|
|
|
}
|