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

Added support for debug CLI flag. #1322

Merged
merged 9 commits into from
Aug 29, 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
25 changes: 15 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@ Description of the upcoming release here.

### Added

- [#1274](https://github.com/FuelLabs/fuel-core/pull/1274): Added tests to benchmark block synchronization.
- [#1309](https://github.com/FuelLabs/fuel-core/pull/1309): Add documentation for running debug builds with CLion and Visual Studio Code.
- [#1308](https://github.com/FuelLabs/fuel-core/pull/1308): Add support for loading .env files when compiling with the `env` feature. This allows users to conveniently supply CLI arguments in a secure and IDE-agnostic way.
- [#1263](https://github.com/FuelLabs/fuel-core/pull/1263): Add gas benchmarks for `ED19` and `ECR1` instructions.
- [#1286](https://github.com/FuelLabs/fuel-core/pull/1286): Include readable names for test cases where missing.
- [#1304](https://github.com/FuelLabs/fuel-core/pull/1304): Implemented `submit_and_await_commit_with_receipts` method for `FuelClient`.
- [#1286](https://github.com/FuelLabs/fuel-core/pull/1286): Include readable names for test cases where missing.
- [#1274](https://github.com/FuelLabs/fuel-core/pull/1274): Added tests to benchmark block synchronization.
- [#1263](https://github.com/FuelLabs/fuel-core/pull/1263): Add gas benchmarks for `ED19` and `ECR1` instructions.

#### Breaking

- [#1322](https://github.com/FuelLabs/fuel-core/pull/1322):
The `debug` flag is added to the CLI. The flag should be used for local development only. Enabling debug mode:
- Allows GraphQL Endpoints to arbitrarily advance blocks.
- Enables debugger GraphQL Endpoints.
- Allows setting `utxo_validation` to `false`.

### Changed

Expand All @@ -28,15 +36,12 @@ Description of the upcoming release here.

#### Breaking
- [#1318](https://github.com/FuelLabs/fuel-core/pull/1318): Removed the `--sync-max-header-batch-requests` CLI argument, and renamed `--sync-max-get-txns` to `--sync-block-stream-buffer-size` to better represent the current behavior in the import.
- [#1290](https://github.com/FuelLabs/fuel-core/pull/1290): Standardize CLI args to use `-` instead of `_`.
- [#1279](https://github.com/FuelLabs/fuel-core/pull/1279): Added a new CLI flag to enable the Relayer service `--enable-relayer`, and disabled the Relayer service by default. When supplying the `--enable-relayer` flag, the `--relayer` argument becomes mandatory, and omitting it is an error. Similarly, providing a `--relayer` argument without the `--enable-relayer` flag is an error. Lastly, providing the `--keypair` or `--network` arguments will also produce an error if the `--enable-p2p` flag is not set.
- [#1262](https://github.com/FuelLabs/fuel-core/pull/1262): The `ConsensusParameters` aggregates all configuration data related to the consensus. It contains many fields that are segregated by the usage. The API of some functions was affected to use lesser types instead the whole `ConsensusParameters`. It is a huge breaking change requiring repetitively monotonically updating all places that use the `ConsensusParameters`. But during updating, consider that maybe you can use lesser types. Usage of them may simplify signatures of methods and make them more user-friendly and transparent.
- [#1290](https://github.com/FuelLabs/fuel-core/pull/1290): Standardize CLI args to use `-` instead of `_`

### Fixed

- Some fix here 1
- Some fix here 2
### Removed

#### Breaking
- Some breaking fix here 3
- Some breaking fix here 4
- [#1322](https://github.com/FuelLabs/fuel-core/pull/1322): The `manual_blocks_enabled` flag is removed from the CLI. The analog is a `debug` flag.

3 changes: 1 addition & 2 deletions bin/fuel-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ url = { version = "2.2", optional = true }
test-case = { workspace = true }

[features]
debug = ["env", "fuel-core/debug"]
default = ["debug", "metrics", "relayer", "rocksdb"]
default = ["env", "metrics", "relayer", "rocksdb"]
env = ["dep:dotenvy"]
metrics = ["fuel-core/metrics"]
p2p = ["fuel-core/p2p", "const_format"]
Expand Down
18 changes: 11 additions & 7 deletions bin/fuel-core/src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@ pub struct Command {
)]
pub chain_config: String,

/// Allows GraphQL Endpoints to arbitrarily advanced blocks. Should be used for local development only
#[arg(long = "manual-blocks-enabled", env)]
pub manual_blocks_enabled: bool,
/// Should be used for local development only. Enabling debug mode:
/// - Allows GraphQL Endpoints to arbitrarily advance blocks.
/// - Enables debugger GraphQL Endpoints.
/// - Allows setting `utxo_validation` to `false`.
#[arg(long = "debug", env)]
pub debug: bool,

/// Enable logging of backtraces from vm errors
#[arg(long = "vm-backtrace", env)]
Expand Down Expand Up @@ -206,7 +209,7 @@ impl Command {
database_type,
chain_config,
vm_backtrace,
manual_blocks_enabled,
debug,
utxo_validation,
min_gas_price,
consensus_key,
Expand Down Expand Up @@ -286,14 +289,14 @@ impl Command {
max_wait_time: max_wait_time.into(),
};

Ok(Config {
let config = Config {
addr,
max_database_cache_size,
database_path,
database_type,
chain_conf: chain_conf.clone(),
debug,
utxo_validation,
manual_blocks_enabled,
block_production: trigger,
vm: VMConfig {
backtrace: vm_backtrace,
Expand Down Expand Up @@ -327,7 +330,8 @@ impl Command {
min_connected_reserved_peers,
time_until_synced: time_until_synced.into(),
query_log_threshold_time: query_log_threshold_time.into(),
})
};
Ok(config)
}
}

Expand Down
5 changes: 2 additions & 3 deletions crates/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ fuel-core-types = { workspace = true, features = ["serde", "test-helpers"] }
insta = { workspace = true }

[build-dependencies]
schemafy_lib = { version = "0.5", optional = true }
serde_json = { version = "1.0", features = ["raw_value"], optional = true }
schemafy_lib = { version = "0.5" }
serde_json = { version = "1.0", features = ["raw_value"] }

[features]
default = ["subscriptions"]
test-helpers = []
dap = ["schemafy_lib", "serde_json"]
subscriptions = ["eventsource-client", "futures", "hyper-rustls"]
2 changes: 0 additions & 2 deletions crates/client/build.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
fn main() {
println!("cargo:rerun-if-changed=./assets/debugAdapterProtocol.json");

#[cfg(feature = "dap")]
generate_dap_schema();
}

#[cfg(feature = "dap")]
fn generate_dap_schema() {
use schemafy_lib::{
Expander,
Expand Down
1 change: 0 additions & 1 deletion crates/client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![deny(unused_crate_dependencies)]
#![deny(warnings)]
pub mod client;
#[cfg(feature = "dap")]
pub mod schema;
6 changes: 2 additions & 4 deletions crates/fuel-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
tokio-stream = { workspace = true, features = ["sync"] }
tower-http = { version = "0.3", features = ["set-header", "trace"] }
tracing = { workspace = true }
uuid = { version = "1.1", features = ["v4"], optional = true }
uuid = { version = "1.1", features = ["v4"] }

[dev-dependencies]
assert_matches = "1.5"
Expand All @@ -73,9 +73,7 @@ test-case = { workspace = true }
test-strategy = { workspace = true }

[features]
dap = ["dep:uuid"]
debug = ["fuel-core-types/debug", "dap"]
default = ["debug", "metrics", "rocksdb"]
default = ["metrics", "rocksdb"]
metrics = ["dep:fuel-core-metrics"]
p2p = ["dep:fuel-core-p2p", "dep:fuel-core-sync"]
relayer = ["dep:fuel-core-relayer"]
Expand Down
2 changes: 1 addition & 1 deletion crates/fuel-core/src/graphql_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub mod service;
pub struct Config {
pub addr: SocketAddr,
pub utxo_validation: bool,
pub manual_blocks_enabled: bool,
pub debug: bool,
pub vm_backtrace: bool,
pub min_gas_price: u64,
pub max_tx: usize,
Expand Down
22 changes: 0 additions & 22 deletions crates/fuel-core/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ pub mod block;
pub mod chain;
pub mod coins;
pub mod contract;
#[cfg(feature = "dap")]
pub mod dap;
pub mod health;
pub mod message;
pub mod node_info;
pub mod scalars;
pub mod tx;

#[cfg(feature = "dap")]
#[derive(MergedObject, Default)]
pub struct Query(
dap::DapQuery,
Expand All @@ -48,29 +46,9 @@ pub struct Query(
message::MessageQuery,
);

#[cfg(not(feature = "dap"))]
#[derive(MergedObject, Default)]
pub struct Query(
balance::BalanceQuery,
block::BlockQuery,
chain::ChainQuery,
tx::TxQuery,
health::HealthQuery,
coins::CoinQuery,
contract::ContractQuery,
contract::ContractBalanceQuery,
node_info::NodeQuery,
message::MessageQuery,
);

#[cfg(feature = "dap")]
#[derive(MergedObject, Default)]
pub struct Mutation(dap::DapMutation, tx::TxMutation, block::BlockMutation);

#[cfg(not(feature = "dap"))]
#[derive(MergedObject, Default)]
pub struct Mutation(tx::TxMutation, block::BlockMutation);

#[derive(MergedSubscription, Default)]
pub struct Subscription(tx::TxStatusSubscription);

Expand Down
6 changes: 2 additions & 4 deletions crates/fuel-core/src/schema/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,8 @@ impl BlockMutation {
let consensus_module = ctx.data_unchecked::<ConsensusModule>();
let config = ctx.data_unchecked::<GraphQLConfig>().clone();

if !config.manual_blocks_enabled {
return Err(
anyhow!("Manual Blocks must be enabled to use this endpoint").into(),
)
if !config.debug {
return Err(anyhow!("`debug` must be enabled to use this endpoint").into())
}

let start_time = start_timestamp.map(|timestamp| timestamp.0);
Expand Down
Loading
Loading