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

feat: add forc-node command for easily bootstrapping a node #6473

Open
wants to merge 30 commits into
base: master
Choose a base branch
from

Conversation

kayagokalp
Copy link
Member

@kayagokalp kayagokalp commented Aug 28, 2024

Description

WIP at the moment, I have couple of code duplications to remove but we can start playing with this.

Forc Node

Forc node is a new plugin for easily bootstrapping fuel-core instances with sensible defaults. We currently support:

  1. Ignition
  2. Testnet
  3. Local

Ignition

This configuration automatically syncs with ignition network, basically run forc node ignition and the created node instance will start syncing.

The defaults are taken from: https://docs.fuel.network/guides/running-a-node/running-a-mainnet-node/

> ./target/debug/forc-node ignition
✔ Do you have a keypair in hand? · yes
✔ Peer Id: · 16Uiu2HAm6U2QNh35FAoob8LNS9zA6tz4BSrsyCmJxgpEzmYRNgrk
✔ Secret: · ********
? Ethereum RPC (Sepolia) Endpoint: › https://eth-mainnet.g.alchemy.com/v2/....
2024-11-28T06:06:36.369956Z  INFO fuel_core_bin::cli::run: 315: `[Importer, P2P, Producer, TxPool, GraphQL]` metrics are enabled
2024-11-28T06:06:36.370965Z  INFO fuel_core_bin::cli::run: 345: Block production disabled
2024-11-28T06:06:36.370973Z  WARN fuel_core_bin::cli::run: 405: The coinbase recipient `ContractId` is not set!
2024-11-28T06:06:36.370981Z  INFO fuel_core_bin::cli::run: 608: Fuel Core version v0.40.0
...

Testnet

This is for connecting to the latest testnet. Similar to mainnet only thing required is to run forc node testnet to start a node created for syncing with testnet.

The defaults are taken from: https://docs.fuel.network/guides/running-a-node/running-a-testnet-node/

> ./target/debug/forc-node testnet
✔ Do you have a keypair in hand? · yes
✔ Peer Id: · 16Uiu2HAm6U2QNh35FAoob8LNS9zA6tz4BSrsyCmJxgpEzmYRNgrk
✔ Secret: · ********
? Ethereum RPC (Sepolia) Endpoint: › https://eth-sepolia.g.alchemy.com/v2/....
2024-11-28T06:06:36.369956Z  INFO fuel_core_bin::cli::run: 315: `[Importer, P2P, Producer, TxPool, GraphQL]` metrics are enabled
2024-11-28T06:06:36.370965Z  INFO fuel_core_bin::cli::run: 345: Block production disabled
2024-11-28T06:06:36.370973Z  WARN fuel_core_bin::cli::run: 405: The coinbase recipient `ContractId` is not set!
2024-11-28T06:06:36.370981Z  INFO fuel_core_bin::cli::run: 608: Fuel Core version v0.40.0
...

Local

This is a in-memory instance mostly suited for local developments with instant block production and debug mode enabled in the fuel-core level.

> ./target/debug/forc-node local
2024-11-28T06:04:44.654891Z  INFO fuel_core_bin::cli::run: 315: `[Importer, P2P, Producer, TxPool, GraphQL]` metrics are enabled
2024-11-28T06:04:44.655762Z  INFO fuel_core_bin::cli::run::relayer: 56: Relayer service disabled
2024-11-28T06:04:44.655769Z  INFO fuel_core_bin::cli::run::p2p: 259: P2P service disabled
2024-11-28T06:04:44.655797Z  INFO fuel_core_bin::cli::run: 343: Block production mode: Instant
...

Dry run

It is possible that users of this new plugin might not want to run the node without seeing the parameters send to it. So forc-node has a dry run mode that can be enabled forc-node --dry-run <ignition|testnet|local> which will instead of running the node print the command that would achieve the same result:

> ./target/debug/forc-node --dry-run local
fuel-core run --debug --snapshot /Users/kayagokalp/.forc/chainspecs/local --db-type in-memory --poa-instant true

TODO

  • [] Add docs to sway book plugins section
  • [] Add CI check to compare cargo fuel-core version with min supported

@kayagokalp kayagokalp force-pushed the kayagokalp/forc-node-local branch from bd90b81 to 4cab4db Compare November 28, 2024 05:47
Copy link
Member

@mchristopher mchristopher left a comment

Choose a reason for hiding this comment

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

Small comments.

Also, can we remove the wasm bytecodes & benchmark JSON files? Those are not needed at runtime (it will pull updates from the live network if needed), and I don't like committing or shipping binary blobs in this repo if we can avoid it.

forc-plugins/forc-node/src/consts.rs Outdated Show resolved Hide resolved
forc-plugins/forc-node/src/consts.rs Outdated Show resolved Hide resolved
@kayagokalp kayagokalp force-pushed the kayagokalp/forc-node-local branch from 4cab4db to 2db09cc Compare December 2, 2024 23:16
@kayagokalp kayagokalp self-assigned this Dec 2, 2024
@kayagokalp kayagokalp added enhancement New feature or request forc labels Dec 4, 2024
@kayagokalp kayagokalp force-pushed the kayagokalp/forc-node-local branch from 5873fab to fadc4ee Compare December 12, 2024 07:01
@kayagokalp kayagokalp marked this pull request as ready for review December 12, 2024 07:06
@kayagokalp kayagokalp requested review from a team as code owners December 12, 2024 07:06
@kayagokalp kayagokalp force-pushed the kayagokalp/forc-node-local branch from 5e2f71c to 91b8e10 Compare December 12, 2024 07:06
@zees-dev
Copy link
Contributor

zees-dev commented Dec 12, 2024

opinion: I've seen dry-run mostly used for making transactions or some state-changing/persisting action; I personally think that the default command run when starting up the node should be printed in the --help output instead.
Alternatively, if we still want to continue using dry-run for this; then it should adapt with the CLI flags; for example when running:

cargo run -p forc-node -- --dry-run local --port 8090

It prints the following (port is missing):

fuel-core run --debug --snapshot /Users/z/.forc/chainspecs/local --db-type in-memory --poa-instant true

Copy link
Member

@sdankel sdankel left a comment

Choose a reason for hiding this comment

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

Great work on this! 🏆

forc-plugins/forc-node/src/cmd.rs Outdated Show resolved Hide resolved
forc-plugins/forc-node/src/cmd.rs Outdated Show resolved Hide resolved
forc-plugins/forc-node/src/ignition/cmd.rs Show resolved Hide resolved
forc-plugins/forc-node/src/consts.rs Show resolved Hide resolved

fn build_api_endpoint(&self, folder_name: &str) -> String {
format!(
"{}/repos/FuelLabs/{}/contents/{}",
Copy link
Member

Choose a reason for hiding this comment

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

If we're always fetching from master, would this mean forc-node might be using a newer version of the chain config than what's actually deployed?

forc-plugins/forc-node/src/run_opts.rs Show resolved Hide resolved
forc-plugins/forc-node/src/chain_config.rs Show resolved Hide resolved
forc-plugins/forc-node/src/util.rs Show resolved Hide resolved
@kayagokalp
Copy link
Member Author

kayagokalp commented Jan 17, 2025

I'll move forc-node tests to a sepearate step because it needs fuel-core installed. That's why test workspace stuff is failing but the code itself is ready to be reviewed! @FuelLabs/tooling

@kayagokalp kayagokalp force-pushed the kayagokalp/forc-node-local branch from db7a38f to f59a38b Compare January 21, 2025 20:27
@kayagokalp kayagokalp requested review from a team as code owners January 23, 2025 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request forc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants