Skip to content
This repository has been archived by the owner on Dec 26, 2024. It is now read-only.

build: add option to compile the node without rpc #1689

Merged
merged 1 commit into from
Mar 17, 2024

Conversation

ShahakShama
Copy link
Contributor

@ShahakShama ShahakShama commented Feb 8, 2024

This change is Reviewable

Copy link

codecov bot commented Feb 8, 2024

Codecov Report

Attention: Patch coverage is 82.85714% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 71.85%. Comparing base (88f2623) to head (a84e89f).
Report is 1 commits behind head on main.

Files Patch % Lines
crates/papyrus_node/src/bin/dump_config.rs 0.00% 5 Missing ⚠️
crates/papyrus_node/src/main.rs 95.23% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1689   +/-   ##
=======================================
  Coverage   71.84%   71.85%           
=======================================
  Files         141      141           
  Lines       20201    20224   +23     
  Branches    20201    20224   +23     
=======================================
+ Hits        14514    14532   +18     
- Misses       3515     3521    +6     
+ Partials     2172     2171    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ShahakShama ShahakShama force-pushed the shahak/feature_for_rpc branch 2 times, most recently from ae611b1 to a37d3f3 Compare February 11, 2024 05:47
Copy link
Contributor

@yair-starkware yair-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 6 of 9 files at r1, 4 of 4 files at r2, all commit messages.
Reviewable status: 9 of 10 files reviewed, 2 unresolved discussions (waiting on @dan-starkware and @ShahakShama)


crates/papyrus_node/src/bin/dump_config.rs line 43 at r2 (raw file):

}

#[cfg(not(feature = "rpc"))]

Does something break if we keep the RPC config in the default file in the scenario of no rpc?
If not, I think we should avoid creating another default config file.


crates/papyrus_node/src/bin/dump_config.rs line 76 at r2 (raw file):

/// Updates the default config file by:
/// cargo run --bin dump_config -q

Don't we need to run without the rpc feature somehow in case we want to keep both default files?

Code quote:

cargo run --bin dump_config -q

@ShahakShama ShahakShama force-pushed the shahak/feature_for_rpc branch from a37d3f3 to a705612 Compare February 14, 2024 08:13
Copy link
Contributor Author

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 7 of 10 files reviewed, 2 unresolved discussions (waiting on @dan-starkware and @yair-starkware)


crates/papyrus_node/src/bin/dump_config.rs line 43 at r2 (raw file):

Previously, yair-starkware (Yair) wrote…

Does something break if we keep the RPC config in the default file in the scenario of no rpc?
If not, I think we should avoid creating another default config file.

Done.


crates/papyrus_node/src/bin/dump_config.rs line 76 at r2 (raw file):

Previously, yair-starkware (Yair) wrote…

Don't we need to run without the rpc feature somehow in case we want to keep both default files?

Done.

@ShahakShama ShahakShama force-pushed the shahak/feature_for_rpc branch from a705612 to e13238b Compare February 14, 2024 08:59
Copy link
Contributor

@yair-starkware yair-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 5 of 5 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @dan-starkware and @ShahakShama)


crates/papyrus_node/src/main.rs line 5 at r3 (raw file):

use std::env::args;
use std::future::{self, pending, Future};

Is this on purpose?

Code quote:

self

crates/papyrus_node/src/bin/dump_config.rs line 72 at r3 (raw file):

        ),
        vec!["monitoring_gateway.collect_metrics".to_owned()],
    )];

Do we still need this extra code? We don't dump default config for no rpc anymore, right?

Code quote:

#[cfg(not(feature = "rpc"))]
lazy_static! {
    /// Returns vector of (pointer target name, pointer target serialized param, vec<pointer param path>)
    /// to be applied on the dumped node config.
    /// The config updates will be performed on the shared pointer targets, and finally, the values
    /// will be propagated to the pointer params.
    static ref CONFIG_POINTERS: Vec<((ParamPath, SerializedParam), Vec<ParamPath>)> = vec![(
        ser_pointer_target_param(
            "chain_id",
            &ChainId("SN_MAIN".to_string()),
            "The chain to follow. For more details see https://docs.starknet.io/documentation/architecture_and_concepts/Blocks/transactions/#chain-id.",
        ),
        vec!["storage.db_config.chain_id".to_owned()],
    ),
    (
        ser_pointer_target_param(
            "starknet_url",
            &"https://alpha-mainnet.starknet.io/".to_string(),
            "The URL of a centralized Starknet gateway.",
        ),
        vec!["central.url".to_owned(), "monitoring_gateway.starknet_url".to_owned()],
    ),
    (
        ser_pointer_target_param(
            "collect_metrics",
            &false,
            "If true, collect metrics for the node.",
        ),
        vec!["monitoring_gateway.collect_metrics".to_owned()],
    )];

Copy link
Contributor Author

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @dan-starkware and @yair-starkware)


crates/papyrus_node/src/main.rs line 5 at r3 (raw file):

Previously, yair-starkware (Yair) wrote…

Is this on purpose?

This is a rebase result. See the full diff and it will be clearer


crates/papyrus_node/src/bin/dump_config.rs line 72 at r3 (raw file):

Previously, yair-starkware (Yair) wrote…

Do we still need this extra code? We don't dump default config for no rpc anymore, right?

Yes, as the destination of the pointers changes between the features. This has nothing to do with the default config

@ShahakShama ShahakShama force-pushed the shahak/feature_for_rpc branch 2 times, most recently from 3a25d20 to 0801a30 Compare February 14, 2024 10:26
Copy link
Contributor

@yair-starkware yair-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dan-starkware and @ShahakShama)


crates/papyrus_node/src/bin/dump_config.rs line 6 at r5 (raw file):

#[cfg(feature = "rpc")]
use lazy_static::lazy_static;

Put everything in a module and use #[cfg(feature = "rpc")] on the whole thing

Copy link
Contributor Author

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 9 of 11 files reviewed, 1 unresolved discussion (waiting on @dan-starkware and @yair-starkware)


crates/papyrus_node/src/bin/dump_config.rs line 6 at r5 (raw file):

Previously, yair-starkware (Yair) wrote…

Put everything in a module and use #[cfg(feature = "rpc")] on the whole thing

Done.

Copy link
Contributor

@yair-starkware yair-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dan-starkware and @ShahakShama)


crates/papyrus_node/src/bin/dump_config.rs line 6 at r5 (raw file):

Previously, ShahakShama wrote…

Done.

I meant in the same file but I guess that's fine.
Also make a function that will be called in main so all the use statements can be in the module too

Copy link
Contributor Author

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dan-starkware and @yair-starkware)


crates/papyrus_node/src/bin/dump_config.rs line 6 at r5 (raw file):

Previously, yair-starkware (Yair) wrote…

I meant in the same file but I guess that's fine.
Also make a function that will be called in main so all the use statements can be in the module too

Done.

@ShahakShama ShahakShama force-pushed the shahak/feature_for_rpc branch from dd3a245 to 99ace0d Compare February 14, 2024 11:00
yair-starkware
yair-starkware previously approved these changes Feb 14, 2024
Copy link
Contributor

@yair-starkware yair-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 2 files at r8, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @dan-starkware)

Copy link
Collaborator

@dan-starkware dan-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @ShahakShama)


.github/workflows/ci.yml line 118 at r8 (raw file):

      - run: |
          cargo test -p papyrus_node --no-default-features

Can we have something more explicit, like --no-rpc

Code quote:

no-default-features

crates/papyrus_node/src/main.rs line 71 at r8 (raw file):

    _storage_reader: StorageReader,
) -> anyhow::Result<impl Future<Output = Result<(), JoinError>>> {
    Ok(futures::future::pending())

Please explain the difference between this pending and the one imported, sort the multiple pending

Code quote:

(futures::future::pending(

crates/papyrus_node/src/main.rs line 100 at r8 (raw file):

        block: PendingBlockOrDeprecated::Current(PendingBlock {
            parent_block_hash: BlockHash(
                GENESIS_HASH.try_into().expect("Failed converting genesis hash to StarkHash"),

Is it related to this PR?

Code quote:

 GENESIS_HASH.try_into().expect("Failed converting genesis hash to StarkHash"),

crates/papyrus_node/src/main_test.rs line 23 at r8 (raw file):

#[cfg(not(feature = "rpc"))]
fn fix_execution_config_path(_config: &mut NodeConfig) {}

Please explain why RPC and execution are coupled here

Code quote:

#[cfg(feature = "rpc")]
fn fix_execution_config_path(config: &mut NodeConfig) {
    let default_execution_config_path = RpcConfig::default().execution_config;
    config.rpc.execution_config =
        get_absolute_path(default_execution_config_path.to_str().unwrap());
}

#[cfg(not(feature = "rpc"))]
fn fix_execution_config_path(_config: &mut NodeConfig) {}

crates/papyrus_node/src/bin/dump_config.rs line 59 at r8 (raw file):

    with_rpc::dump_config();
    // TODO(shahak): Try to find a way to remove this binary altogether when the feature rpc is
    // turned off.

Please check this and otherwise move the inner module into a separate file

Code quote:

    // TODO(shahak): Try to find a way to remove this binary altogether when the feature rpc is
    // turned off.

crates/papyrus_node/src/config/mod.rs line 45 at r8 (raw file):

pub struct NodeConfig {
    #[validate]
    pub rpc: RpcConfig,

I would expect this to be conditionally as well

Code quote:

pub rpc: RpcConfig,

crates/papyrus_node/src/config/mod.rs line 99 at r8 (raw file):

}

// TODO(shahak): Try to make this config empty.

What fails?

Code quote:

Try to make this config empty

Copy link
Contributor Author

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 3 of 12 files reviewed, 3 unresolved discussions (waiting on @dan-starkware and @yair-starkware)


.github/workflows/ci.yml line 118 at r8 (raw file):

Previously, dan-starkware wrote…

Can we have something more explicit, like --no-rpc

Sadly no rust-lang/cargo#3126


crates/papyrus_node/src/main.rs line 100 at r8 (raw file):

Previously, dan-starkware wrote…

Is it related to this PR?

Yes. I fixed it by changing starknet api in the Cargo.toml to be with feature testing but I think this shows we shouldn't use this macro here. WDYT?


crates/papyrus_node/src/bin/dump_config.rs line 59 at r8 (raw file):

Previously, dan-starkware wrote…

Please check this and otherwise move the inner module into a separate file

Looks like someone else moved it to a separate module for me :)


crates/papyrus_node/src/config/mod.rs line 45 at r8 (raw file):

Previously, dan-starkware wrote…

I would expect this to be conditionally as well

Done.


crates/papyrus_node/src/config/mod.rs line 99 at r8 (raw file):

Previously, dan-starkware wrote…

What fails?

Irrelevant due to previous comment

Copy link
Collaborator

@dan-starkware dan-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 4 files at r2, 1 of 5 files at r3, 8 of 9 files at r9, all commit messages.
Reviewable status: 11 of 12 files reviewed, all discussions resolved (waiting on @yair-starkware)

@ShahakShama ShahakShama force-pushed the shahak/feature_for_rpc branch from 02d601e to a84e89f Compare March 17, 2024 12:07
Copy link
Collaborator

@dan-starkware dan-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 9 files at r9, 2 of 2 files at r10, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ShahakShama)

Copy link
Collaborator

@dan-starkware dan-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 2 files at r8.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ShahakShama)

@ShahakShama ShahakShama added this pull request to the merge queue Mar 17, 2024
Merged via the queue into main with commit 01a2252 Mar 17, 2024
18 checks passed
@ShahakShama ShahakShama deleted the shahak/feature_for_rpc branch March 17, 2024 12:40
@github-actions github-actions bot locked and limited conversation to collaborators Mar 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants