Skip to content

Commit c9ee8ad

Browse files
JoshuaBattykayagokalpsdankelIGI-111Dentosal
authored
Migrate forc-node from the sway repo (#130)
* feat: add forc-node command for easily bootstrapping a node (#6473) * chore: move dev dependencies to workspace (#6966) ## Description Moves dev dependencies to the workspace Cargo.toml for consistent versions in tests. Inspired by FuelLabs/sway#6955 ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. * ci: upgrade to rust 1.85.0 (#6979) ## Description ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. * Add description to forc-node (#7013) ## Description Descriptions are required for crates.io published packages. ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. * fix: ensure forc-node ignition fetches ignition chain config (#7194) ## Description closes #7193. There was a simple bug in the mainnet setup we were still fetching testnet configuration. Which caused some syncing issues. * Bump fuel deps (#7228) ## Description Bumps fuel-vm, fuel-core fuels-rs and forc-wallet to latest versions. Upgrades Rust to 2021 edition. ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [x] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [x] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - I believe this is non-breaking from user code perspective but I'm not too sure about that - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: z <zees-dev@users.noreply.github.com> Co-authored-by: zees-dev <63374656+zees-dev@users.noreply.github.com> Co-authored-by: JoshuaBatty <joshpbatty@gmail.com> Co-authored-by: IGI-111 <igi-111@protonmail.com> * feat: check file descriptor limits before running forc node (#7302) ## Description Adds a check to try and set the `NOFILE` limit on Unix-based systems. This is important for RocksDB, since we generally exceed the default maximum number of allowed file descriptors allowed by the OS. The idea is to attempt to raise that limit to a reasonable number, and throw an error if we are unable to (likely due to user permission issues). ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. * Apply Clippy's `uninlined_format_args` lint (#7361) ## Description This PR improves the readability of `format!`, `write!`, etc. macros by rolling out the Clippy fixes for the `uninlined_format_args` lint. `cargo clippy` started showing this lint after locally switching to Cargo v1.88.0. Additionally, the PR: - replaces a few occurrences of `io::Error::new(std::io::ErrorKind::Other, <msg>)` with `io::Error::other(<msg>)`. - replaces a single occurrence of `if params.iter().any(|&p| p == "all")` with `if params.contains(&"all")`. ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers. * refactor: forc-node as lib (#7353) ## Description This PR fundamentally refactors the `forc-node` plugin architecture by embedding the Fuel Core node directly as an in-process library rather than spawning it as a subprocess. This architectural change modernizes the forc-node plugin and lays the groundwork for advanced local development features. ## 🔄 Changes Overview ### Core Architectural Changes - **In-Process Execution**: Fuel Core now runs within the same process as the plugin, eliminating subprocess management overhead - **Direct Integration**: Replaced subprocess spawning with direct library calls to fuel-core - **Unified Logging**: Consolidated logging and error handling across all execution modes - **Improved Configuration**: Enhanced configuration display and management for better debugging ### Dependency Updates - Added direct fuel-core dependencies - Added fuel-core-chain-config for configuration management - Integrated tracing and tracing-subscriber for improved logging - Updated Cargo.lock with necessary transitive dependencies ## 💡 Motivation ### Current Limitations - Subprocess management adds complexity and potential failure points - Limited ability to extend node functionality - Difficult to implement advanced features like state forking (planned feature) ### Benefits of This Change 1. **Performance**: Eliminates IPC overhead and reduces startup time 2. **Reliability**: Direct function calls are more reliable than subprocess communication 3. **Extensibility**: Easier to add advanced features in future PRs ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: z <zees-dev@users.noreply.github.com> Co-authored-by: Joshua Batty <joshpbatty@gmail.com> Co-authored-by: kaya <20915464+kayagokalp@users.noreply.github.com> * feat: forc node account funding (#7378) ## Description This PR adds support for directly funding accounts when starting a local Fuel node with `forc-node`, eliminating the need to manually edit chainspec files - via specifying `--account` parameter. ## Changes - Added `--account` flag to `forc-node local` command that supports multiple funding formats: - `<account-id>` - funds account with base asset and default amount - `<account-id>:<asset-id>` - funds account with specified asset and default amount - `<account-id>:<asset-id>:<amount>` - funds account with specified asset and amount ## Usage Examples ```bash # Fund single account with default asset and amount forc-node local \ --account 0x54944e5b8189827e470e5a8bacfc6c3667397dc4e1eef7ef3519d16d6d6c6610 # Fund account with custom asset forc-node local \ --account 0x54944e5b8189827e470e5a8bacfc6c3667397dc4e1eef7ef3519d16d6d6c6610:0x0000000000000000000000000000000000000000000000000000000000000002 # Fund account with custom asset and amount forc-node local \ --account 0x54944e5b8189827e470e5a8bacfc6c3667397dc4e1eef7ef3519d16d6d6c6610:0x0000000000000000000000000000000000000000000000000000000000000002:1000000 # Fund multiple accounts forc-node local \ --account 0x54944e5b8189827e470e5a8bacfc6c3667397dc4e1eef7ef3519d16d6d6c6610 \ --account 0xe10f526b192593793b7a1559a391445faba82a1d669e3eb2dcd17f9c121b24b1 ``` ## CLI output <img width="1304" height="254" alt="Screenshot 2025-09-10 at 11 15 41 AM" src="https://github.com/user-attachments/assets/add420e5-a64e-4c82-8605-99aeba7e878a" /> - 5 Initial/funded accounts are provided by forc-node (default 5) - Additional accounts are user provided (optional) - These are introduced in this PR ## Implementation Details - Default amount uses `TESTNET_INITIAL_BALANCE` constant when not specified - Default asset uses the chain's base asset ID when not specified Addresses: https://github.com/FuelLabs/sway/issues/7317 ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [x] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: z <zees-dev@users.noreply.github.com> * Add expressive diagnostics for `Warning::UnusedReturnValue` (#7382) ## Description This PR adds expressive diagnostics for the `UnusedReturnValue` warning that explains how to intentionally ignore a returned value by using `let _ = ...`. The reason for adding the diagnostics was an observed confusion among novice Sway developers in the particular case of using `__dbg` intrinsic as a statement: ```sway __dbg("some debug message"); ``` It was unclear to developers why this usage generates the warning, and also how to remove it. Additionally, the PR fixes some `uninlined_format_args` Clippy warnings. ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [x] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers. * chore: bumpt rust version to 1.90 (#7427) ## Description Bumping the rust version to 1.90 and fixing the clippy lints along the way * forc-node wasm32 removal (#7436) ## Description - Reconfigure the `forc-node` crate to drop the `wasm-executor` feature - disable fuel-core `default features`; explicit feature-set declaration - `forc-node` `local` CLI configurable args: - DB backend - debug mode - historical execution - PoA trigger directly - Adjust the local-node test harness to cover the newly surfaced CLI knobs. - Remove the `wasm32-unknown-unknown` build target from CI and GitHub Pages workflows. - Regenerate Cargo.lock after the dependency and feature changes. ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: z <zees-dev@users.noreply.github.com> * Update to latest `fuels-rs` dependency (#7468) ## Description Update to latest `fuels-rs` dependency. ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [x] I have added tests that prove my fix is effective or that my feature works. - [x] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Upgrade to latest Fuel/fuels versions and refactor code/tests to new APIs (IDs, receipts, storage, wallet, node owner). > > - **Dependencies**: > - Bump `fuel-core` to `0.47.x`, `fuel-{vm,tx,types,asm,crypto}` to `0.65`, and `fuels{,-core,-accounts}` to `0.76`; update `fuel-core-*` crates across workspace and SDK harness. > - **Core/API migrations**: > - Use `Contract::id(..)` associated function (replaces instance method); update contract ID calculations in `forc-pkg`, `forc-client` deploy, and `forc-test`. > - Adjust receipts handling to `Arc<Vec<_>>` and convert as needed; update parsing/printing of `Receipt::LogData`/`ReturnData` to new byte accessors. > - Update `ContractsStateData` construction and storage conversions in VM trace storage. > - Refactor wallet account collection/types and secret key conversion in tx utils. > - Switch `forc-node` coin owner to `Owner` enum; update logging and tests. > - **Tests**: > - Adapt E2E and client tests to new receipt/data APIs and predicate fee assertions; update SDK harness deps and context tests (ContractIdExt import). > - **Misc**: > - Update workspace `Cargo.toml` and `test/src/sdk-harness/Cargo.toml`; extend `.typos.toml` ignores/excludes. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit d0541bd2ec806d10743310573edde8c85364b4ff. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> * update Cargo.toml for forc-node workspace integration --------- Co-authored-by: Kaya Gökalp <kaya.gokalp@fuel.sh> Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com> Co-authored-by: IGI-111 <igi-111@protonmail.com> Co-authored-by: Hannes Karppila <2204863+Dentosal@users.noreply.github.com> Co-authored-by: z <zees-dev@users.noreply.github.com> Co-authored-by: zees-dev <63374656+zees-dev@users.noreply.github.com> Co-authored-by: Mike Christopher <mchristopher@users.noreply.github.com> Co-authored-by: Igor Rončević <ironcev@hotmail.com> Co-authored-by: kaya <20915464+kayagokalp@users.noreply.github.com> Co-authored-by: João Matos <joao@tritao.eu>
1 parent c10463b commit c9ee8ad

19 files changed

Lines changed: 7857 additions & 2136 deletions

File tree

Cargo.lock

Lines changed: 5893 additions & 2136 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
resolver = "2"
33
members = [
44
"forc-crypto",
5+
"forc-node",
56
"forc-tracing",
67
"forc-wallet",
78
]
@@ -14,8 +15,14 @@ repository = "https://github.com/FuelLabs/forc"
1415

1516

1617
[workspace.dependencies]
18+
# Internal dependencies
19+
forc-tracing = { version = "0.71.1", path = "forc-tracing" }
20+
1721
# External Fuel dependencies
22+
fuel-core = { version = "0.47", default-features = false }
23+
fuel-core-chain-config = { version = "0.47", default-features = false }
1824
fuel-core-types = { version = "0.47", default-features = false }
25+
fuel-crypto = "0.65"
1926
forc-util = "0.70.2"
2027

2128
# External dependencies
@@ -24,18 +31,24 @@ anyhow = "1.0"
2431
async-trait = "0.1"
2532
clap = "4.5"
2633
criterion = "0.5"
34+
dialoguer = "0.11"
2735
eth-keystore = "0.5"
2836
futures = { version = "0.3", default-features = false }
2937
hex = "0.4"
3038
home = "0.5"
39+
libc = "0.2"
3140
libp2p-identity = "0.2"
41+
portpicker = "0.1"
3242
rand = "0.8"
3343
rayon = "1.7"
3444
regex = "1.10"
45+
reqwest = "0.12"
3546
rpassword = "7.2"
47+
semver = "1.0"
3648
serde = "1.0"
3749
serde_json = "1.0"
3850
serde_yaml = "0.9"
51+
sha1 = "0.10"
3952
sha3 = "0.10"
4053
tempfile = "3"
4154
termion = "4.0"
@@ -45,6 +58,7 @@ tracing-subscriber = "0.3.19"
4558
tracing-test = "0.2"
4659
serial_test = "3"
4760
url = "2.5"
61+
wiremock = "0.6"
4862

4963
[workspace.lints.rust]
5064
missing_docs = "allow"

forc-node/Cargo.toml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[package]
2+
name = "forc-node"
3+
version = "0.71.0"
4+
description = "a wrapper around fuel-core to bootstrap nodes"
5+
edition = "2021"
6+
authors.workspace = true
7+
homepage.workspace = true
8+
license.workspace = true
9+
repository.workspace = true
10+
11+
[lib]
12+
path = "src/lib.rs"
13+
14+
[[bin]]
15+
name = "forc-node"
16+
path = "src/main.rs"
17+
18+
[dependencies]
19+
anyhow.workspace = true
20+
clap = { workspace = true, features = ["derive", "string"] }
21+
dialoguer.workspace = true
22+
forc-tracing.workspace = true
23+
forc-util.workspace = true
24+
fuel-core = { workspace = true, features = ["relayer", "rocksdb", "test-helpers"] }
25+
fuel-core-chain-config.workspace = true
26+
fuel-core-types.workspace = true
27+
fuel-crypto = { workspace = true, features = ["random"] }
28+
libc.workspace = true
29+
libp2p-identity = { workspace = true, features = ["secp256k1", "peerid"] }
30+
reqwest = { workspace = true, features = ["json"] }
31+
semver.workspace = true
32+
serde.workspace = true
33+
serde_json.workspace = true
34+
sha1.workspace = true
35+
termion.workspace = true
36+
tokio = { workspace = true, features = ["macros", "signal", "rt-multi-thread"] }
37+
tracing.workspace = true
38+
tracing-subscriber.workspace = true
39+
40+
[dev-dependencies]
41+
portpicker.workspace = true
42+
reqwest = { workspace = true, features = ["json"] }
43+
serde_json.workspace = true
44+
tempfile.workspace = true
45+
tokio = { workspace = true, features = ["full"] }
46+
wiremock.workspace = true
47+
48+
[lints]
49+
workspace = true

0 commit comments

Comments
 (0)