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

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
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
4,123 changes: 3,831 additions & 292 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ members = [
"forc-plugins/forc-debug",
"forc-plugins/forc-doc",
"forc-plugins/forc-fmt",
"forc-plugins/forc-lsp",
"forc-plugins/forc-lsp", "forc-plugins/forc-node",
"forc-plugins/forc-tx",
"forc-test",
"forc-tracing",
Expand Down
19 changes: 19 additions & 0 deletions forc-plugins/forc-node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "forc-node"
version = "0.63.1"
edition.workspace = true
authors.workspace = true
homepage.workspace = true
license.workspace = true
repository.workspace = true

[dependencies]
anyhow = "1"
clap = { version = "4.5.4", features = ["derive", "env"] }
forc-util = { version = "0.63.1", path = "../../forc-util" }
forc-tracing = { version = "0.63.1", path = "../../forc-tracing" }
fuel-core-bin = { version = "0.34", features = ["p2p", "relayer", "rocksdb"] }
humantime = "2.1.0"
include_dir = "0.7.4"
tokio = { version = "1.8", features = ["macros", "rt-multi-thread", "process"] }
dialoguer = "0.11.0"
34 changes: 34 additions & 0 deletions forc-plugins/forc-node/chain_configs/local/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# The configuration of the local network

## Chain config
- The `ChainId` is `0`.
- The initial `privileged_address` which can perform the network upgrade:
```shell
{"address":"9f0e19d6c2a6283a3222426ab2630d35516b1799b503f37b02105bebe1b8a3e9","secret":"d80a243ef91956f626d1dad2f23bdfeb73fd0b363282b1eb2227ac5964144afb","type":"block_production"}
```
- The public address of the authority node that produces blocks:
```shell
{"address":"e0a9fcde1b73f545252e01b30b50819eb9547d07531fa3df0385c5695736634d","secret":"4dd0cdca64ef56a01fc81891f9beb6d898f19a22b2e287bce91d807fdf46589a","type":"block_production"}
```
- The block gas limit is `30000000`.

### Gas costs

The gas costs was created from the [benchmarks_fuel_core_0_30_0.json](benchmarks_fuel_core_0_30_0.json) benchmark results.
The `new_storage_per_byte` is manually set to be `63`.
The `gtf` is manually set to be `13`.
The "jmpb", "jmpf", "jneb", "jnef", "jnzb", "jnzf" is manually set to be the same price as "jnei".

## State config
- The `coinbase` address hard coded in the genesis contract:
```shell
{"address":"7b4b30b2437b0073e5ba5a9324cf55831d180a89f66332b541827e12e647b751","secret":"9e24cfa071f6c1c4984a17ecf18061a8d0c9c304e7dd7703788bd122bd578650","type":"block_production"}
```
- Contains many wallets with fake ETHs:
- Wallet 1:
```shell
{"address":"6b63804cfbf9856e68e5b6e7aef238dc8311ec55bec04df774003a2c96e0418e","secret":"de97d8624a438121b86a1956544bd72ed68cd69f2c99555b08b1e8c51ffd511c","type":"block_production"}
```
- The base asset contract source code is taken from [here](https://github.com/FuelLabs/fuel-bridge/tree/b0ebf0b01a903f1866156b7c370ff03d6fb4ec49/packages/base-asset).
- The `ContractId` of the contract is `0x7e2becd64cd598da59b4d1064b711661898656c6b1f4918a787156b8965dc83c`.
- The derived(`SubId` is `0000000000000000000000000000000000000000000000000000000000000000`) base `AssetId` from this contract is `0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07`.

Large diffs are not rendered by default.

306 changes: 306 additions & 0 deletions forc-plugins/forc-node/chain_configs/local/chain_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,306 @@
{
"chain_name": "Local testnet",
"consensus_parameters": {
"V1": {
"tx_params": {
"V1": {
"max_inputs": 255,
"max_outputs": 255,
"max_witnesses": 255,
"max_gas_per_tx": 30000000,
"max_size": 112640,
"max_bytecode_subsections": 256
}
},
"predicate_params": {
"V1": {
"max_predicate_length": 102400,
"max_predicate_data_length": 102400,
"max_message_data_length": 102400,
"max_gas_per_predicate": 30000000
}
},
"script_params": {
"V1": {
"max_script_length": 102400,
"max_script_data_length": 102400
}
},
"contract_params": {
"V1": {
"contract_max_size": 102400,
"max_storage_slots": 1760
}
},
"fee_params": {
"V1": {
"gas_price_factor": 92000,
"gas_per_byte": 63
}
},
"chain_id": 0,
"gas_costs": {
"V4": {
"add": 2,
"addi": 2,
"and": 2,
"andi": 2,
"bal": 29,
"bhei": 2,
"bhsh": 2,
"burn": 19976,
"cb": 2,
"cfsi": 2,
"div": 2,
"divi": 2,
"eck1": 1907,
"ecr1": 26135,
"eq": 2,
"exp": 2,
"expi": 2,
"flag": 2,
"gm": 2,
"gt": 2,
"gtf": 13,
"ji": 2,
"jmp": 2,
"jne": 2,
"jnei": 2,
"jnzi": 2,
"jmpf": 2,
"jmpb": 2,
"jnzf": 2,
"jnzb": 2,
"jnef": 2,
"jneb": 2,
"lb": 2,
"log": 102,
"lt": 2,
"lw": 2,
"mint": 18042,
"mlog": 2,
"mod": 2,
"modi": 2,
"move": 2,
"movi": 2,
"mroo": 4,
"mul": 2,
"muli": 2,
"mldv": 3,
"noop": 1,
"not": 2,
"or": 2,
"ori": 2,
"poph": 3,
"popl": 3,
"pshh": 5,
"pshl": 5,
"ret_contract": 53,
"rvrt_contract": 52,
"sb": 2,
"sll": 2,
"slli": 2,
"srl": 2,
"srli": 2,
"srw": 177,
"sub": 2,
"subi": 2,
"sw": 2,
"sww": 17302,
"time": 35,
"tr": 27852,
"tro": 19718,
"wdcm": 2,
"wqcm": 2,
"wdop": 3,
"wqop": 3,
"wdml": 3,
"wqml": 3,
"wddv": 4,
"wqdv": 5,
"wdmd": 8,
"wqmd": 12,
"wdam": 7,
"wqam": 8,
"wdmm": 8,
"wqmm": 8,
"xor": 2,
"xori": 2,
"aloc": {
"LightOperation": {
"base": 2,
"units_per_gas": 15
}
},
"bsiz": {
"LightOperation": {
"base": 17,
"units_per_gas": 790
}
},
"bldd": {
"LightOperation": {
"base": 15,
"units_per_gas": 272
}
},
"cfe": {
"LightOperation": {
"base": 10,
"units_per_gas": 1818181
}
},
"cfei": {
"LightOperation": {
"base": 2,
"units_per_gas": 1000000
}
},
"call": {
"LightOperation": {
"base": 13513,
"units_per_gas": 7
}
},
"ccp": {
"LightOperation": {
"base": 34,
"units_per_gas": 39
}
},
"croo": {
"LightOperation": {
"base": 91,
"units_per_gas": 3
}
},
"csiz": {
"LightOperation": {
"base": 31,
"units_per_gas": 438
}
},
"ed19": {
"LightOperation": {
"base": 3000,
"units_per_gas": 214
}
},
"k256": {
"LightOperation": {
"base": 27,
"units_per_gas": 5
}
},
"ldc": {
"LightOperation": {
"base": 43,
"units_per_gas": 102
}
},
"logd": {
"LightOperation": {
"base": 363,
"units_per_gas": 4
}
},
"mcl": {
"LightOperation": {
"base": 2,
"units_per_gas": 1041
}
},
"mcli": {
"LightOperation": {
"base": 2,
"units_per_gas": 1025
}
},
"mcp": {
"LightOperation": {
"base": 4,
"units_per_gas": 325
}
},
"mcpi": {
"LightOperation": {
"base": 8,
"units_per_gas": 511
}
},
"meq": {
"LightOperation": {
"base": 3,
"units_per_gas": 940
}
},
"retd_contract": {
"LightOperation": {
"base": 305,
"units_per_gas": 4
}
},
"s256": {
"LightOperation": {
"base": 31,
"units_per_gas": 4
}
},
"scwq": {
"HeavyOperation": {
"base": 16346,
"gas_per_unit": 17163
}
},
"smo": {
"LightOperation": {
"base": 40860,
"units_per_gas": 2
}
},
"srwq": {
"HeavyOperation": {
"base": 187,
"gas_per_unit": 179
}
},
"swwq": {
"HeavyOperation": {
"base": 17046,
"gas_per_unit": 16232
}
},
"contract_root": {
"LightOperation": {
"base": 31,
"units_per_gas": 2
}
},
"state_root": {
"HeavyOperation": {
"base": 236,
"gas_per_unit": 122
}
},
"new_storage_per_byte": 63,
"vm_initialization": {
"LightOperation": {
"base": 3957,
"units_per_gas": 48
}
}
}
},
"base_asset_id": "f8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07",
"block_gas_limit": 30000000,
"privileged_address": "9f0e19d6c2a6283a3222426ab2630d35516b1799b503f37b02105bebe1b8a3e9"
}
},
"genesis_state_transition_version": 9,
"consensus": {
"PoAV2": {
"genesis_signing_key": "e0a9fcde1b73f545252e01b30b50819eb9547d07531fa3df0385c5695736634d",
"signing_key_overrides": {}
}
}
}
8 changes: 8 additions & 0 deletions forc-plugins/forc-node/chain_configs/local/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"chain_config": "chain_config.json",
"table_encoding": {
"Json": {
"filepath": "state_config.json"
}
}
}
Loading
Loading