From be423f07f21646623b49da8dca72c1ed2d2403bc Mon Sep 17 00:00:00 2001 From: Call Delegation <106365423+calldelegation@users.noreply.github.com> Date: Wed, 22 Nov 2023 01:18:36 -0500 Subject: [PATCH 1/2] docs: Adding running node requirements (#118) * adding running node requirements * spelling * Updates * Ready for review --- docs/guides/docs/running-a-node/index.mdx | 12 ++++++++++++ spell-check-custom-words.txt | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/guides/docs/running-a-node/index.mdx b/docs/guides/docs/running-a-node/index.mdx index 6d46ea69..007f05d4 100644 --- a/docs/guides/docs/running-a-node/index.mdx +++ b/docs/guides/docs/running-a-node/index.mdx @@ -31,6 +31,18 @@ Running your own node provides several advantages: 1. **Query Freedom:** By hosting your own node, you can execute a higher number of queries without encountering any rate limits. 2. **Network Independence:** Having your own node ensures that you're not reliant on third-party services, giving you full control over your interactions with the Fuel blockchain. +## Hardware Requirements + +| Hardware | Minimum | Recommended | +|------------|----------|-------------| +| Processor | 2 Cores | 8 Cores | +| Memory | 4 GB | 12 GB | +| Storage | 30 GB | 100 GB | + +For low API traffic, an AWS m5.large should be more than sufficient. However, we recommend an AWS m5.4xlarge instance to match the configuration we use for running the network. + +> For regular tasks such as deploying simple contracts and testing contract interactions locally, there is no need to meet all the hardware requirements below. + ## Getting Started Depending on your requirements, you can opt for one of the following setups: diff --git a/spell-check-custom-words.txt b/spell-check-custom-words.txt index e8884c50..62413ac5 100644 --- a/spell-check-custom-words.txt +++ b/spell-check-custom-words.txt @@ -57,4 +57,5 @@ TODO fuelTestnetInlineCode fuelTestnet faucetLink -GQLPlaygroundLink \ No newline at end of file +GQLPlaygroundLink +xlarge \ No newline at end of file From 62b0d0b7d8485037d35029a592a61460a8b6f4d4 Mon Sep 17 00:00:00 2001 From: Sarah Schwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Wed, 22 Nov 2023 12:28:50 -0700 Subject: [PATCH 2/2] docs: improve node guide (#119) --- .gitmodules | 3 + docs/fuel-core | 1 + .../running-a-node/running-a-beta-4-node.mdx | 211 +----------------- .../running-a-node/running-a-local-node.mdx | 88 +++----- spell-check-custom-words.txt | 3 +- src/components/MDXRender.tsx | 9 +- src/lib/plugins/rehype-code.ts | 3 + src/lib/versions.ts | 7 + src/pages/[...slug].tsx | 9 +- src/screens/DocPage.tsx | 1 + 10 files changed, 64 insertions(+), 271 deletions(-) create mode 160000 docs/fuel-core diff --git a/.gitmodules b/.gitmodules index 5745c65d..435676a2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -61,3 +61,6 @@ [submodule "docs/guides/docs/migration-guide/breaking-change-log"] path = docs/guides/docs/migration-guide/breaking-change-log url = https://github.com/FuelLabs/breaking-change-log +[submodule "docs/fuel-core"] + path = docs/fuel-core + url = https://github.com/FuelLabs/fuel-core diff --git a/docs/fuel-core b/docs/fuel-core new file mode 160000 index 00000000..a417952d --- /dev/null +++ b/docs/fuel-core @@ -0,0 +1 @@ +Subproject commit a417952dc6b4633cb7b798415f22122756bb2551 diff --git a/docs/guides/docs/running-a-node/running-a-beta-4-node.mdx b/docs/guides/docs/running-a-node/running-a-beta-4-node.mdx index fb4928d7..cbffe1d9 100644 --- a/docs/guides/docs/running-a-node/running-a-beta-4-node.mdx +++ b/docs/guides/docs/running-a-node/running-a-beta-4-node.mdx @@ -111,213 +111,10 @@ Make sure you save this somewhere safe so you don't need to generate a new key p To run a local node with persistence, you must configure a `chainConfig.json` file. Here is the [specific configuration](https://github.com/FuelLabs/fuel-core/blob/v0.20.4/deployment/scripts/chainspec/beta_chainspec.json) for `beta-4`: -```json -{ - "chain_name": "Testnet Beta 4", - "block_gas_limit": 30000000, - "initial_state": { - "coins": [ - { - "owner": "0xa1184d77d0d08a064e03b2bd9f50863e88faddea4693a05ca1ee9b1732ea99b7", - "amount": "0x1000000000000000", - "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" - }, - { - "owner": "0xb5566df884bee4e458151c2fe4082c8af38095cc442c61e0dc83a371d70d88fd", - "amount": "0x1000000000000000", - "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" - }, - { - "owner": "0x9da7247e1d63d30d69f136f0f8654ee8340362c785b50f0a60513c7edbf5bb7c", - "amount": "0x1000000000000000", - "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" - }, - { - "owner": "0x4b2ca966aad1a9d66994731db5138933cf61679107c3cde2a10d9594e47c084e", - "amount": "0x1000000000000000", - "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" - }, - { - "owner": "0x26183fbe7375045250865947695dfc12500dcc43efb9102b4e8c4d3c20009dcb", - "amount": "0x1000000000000000", - "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" - }, - { - "owner": "0x81f3a10b61828580d06cc4c7b0ed8f59b9fb618be856c55d33decd95489a1e23", - "amount": "0x1000000000000000", - "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" - }, - { - "owner": "0x587aa0482482efea0234752d1ad9a9c438d1f34d2859b8bef2d56a432cb68e33", - "amount": "0x1000000000000000", - "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" - } - ] - }, - "transaction_parameters": { - "contract_max_size": 16777216, - "max_inputs": 255, - "max_outputs": 255, - "max_witnesses": 255, - "max_gas_per_tx": 10000000, - "max_script_length": 1048576, - "max_script_data_length": 1048576, - "max_storage_slots": 255, - "max_predicate_length": 1048576, - "max_predicate_data_length": 1048576, - "max_gas_per_predicate": 10000000, - "gas_price_factor": 92, - "gas_per_byte": 4, - "max_message_data_length": 1048576, - "chain_id": 0 - }, - "gas_costs": { - "add": 1, - "addi": 1, - "aloc": 1, - "and": 1, - "andi": 1, - "bal": 13, - "bhei": 1, - "bhsh": 1, - "burn": 132, - "cb": 1, - "cfei": 1, - "cfsi": 1, - "croo": 16, - "div": 1, - "divi": 1, - "eck1": 951, - "ecr1": 3000, - "ed19": 3000, - "eq": 1, - "exp": 1, - "expi": 1, - "flag": 1, - "gm": 1, - "gt": 1, - "gtf": 1, - "ji": 1, - "jmp": 1, - "jne": 1, - "jnei": 1, - "jnzi": 1, - "jmpf": 1, - "jmpb": 1, - "jnzf": 1, - "jnzb": 1, - "jnef": 1, - "jneb": 1, - "k256": 11, - "lb": 1, - "log": 9, - "lt": 1, - "lw": 1, - "mcpi": 33, - "mint": 135, - "mlog": 1, - "mod": 1, - "modi": 1, - "move": 1, - "movi": 1, - "mroo": 2, - "mul": 1, - "muli": 1, - "mldv": 1, - "noop": 1, - "not": 1, - "or": 1, - "ori": 1, - "ret_contract": 13, - "rvrt_contract": 13, - "s256": 2, - "sb": 1, - "scwq": 13, - "sll": 1, - "slli": 1, - "srl": 1, - "srli": 1, - "srw": 12, - "sub": 1, - "subi": 1, - "sw": 1, - "sww": 43, - "swwq": 44, - "time": 1, - "tr": 105, - "tro": 60, - "wdcm": 1, - "wqcm": 1, - "wdop": 1, - "wqop": 1, - "wdml": 1, - "wqml": 1, - "wddv": 1, - "wqdv": 2, - "wdmd": 3, - "wqmd": 4, - "wdam": 2, - "wqam": 3, - "wdmm": 3, - "wqmm": 3, - "xor": 1, - "xori": 1, - "call": { - "base": 144, - "dep_per_unit": 214 - }, - "ccp": { - "base": 15, - "dep_per_unit": 103 - }, - "csiz": { - "base": 17, - "dep_per_unit": 790 - }, - "ldc": { - "base": 15, - "dep_per_unit": 272 - }, - "logd": { - "base": 26, - "dep_per_unit": 64 - }, - "mcl": { - "base": 1, - "dep_per_unit": 3333 - }, - "mcli": { - "base": 1, - "dep_per_unit": 3333 - }, - "mcp": { - "base": 1, - "dep_per_unit": 2000 - }, - "meq": { - "base": 1, - "dep_per_unit": 2500 - }, - "retd_contract": { - "base": 29, - "dep_per_unit": 62 - }, - "smo": { - "base": 209, - "dep_per_unit": 55 - }, - "srwq": { - "base": 47, - "dep_per_unit": 5 - } - }, - "consensus": { - "PoA": { - "signing_key": "f65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871" - } - } -} -``` + ## Running a Local Node diff --git a/docs/guides/docs/running-a-node/running-a-local-node.mdx b/docs/guides/docs/running-a-node/running-a-local-node.mdx index 757107fd..b5938e60 100644 --- a/docs/guides/docs/running-a-node/running-a-local-node.mdx +++ b/docs/guides/docs/running-a-node/running-a-local-node.mdx @@ -37,71 +37,37 @@ Or to deploy without using a signing key: forc deploy --unsigned --node-url 127.0.0.1:4000/graphql ``` -## Local node (with state persistence) +## Chain Configuration -This node does persist the blockchain state locally. +To modify the initial state of the chain, you must configure a `chainConfig.json` file. +Here is an example of what that looks like using version {props.fuelCoreVersion} of `fuel-core`: + + + +To start the node with a custom configuration, you can use the command below: -To run a local node with persistence, you must configure a `chainConfig.json` file. Here is an example of what that looks like: - -```json -{ - "chain_name": "local_testnet", - "block_production": { - "ProofOfAuthority": { - "trigger": "instant" - } - }, - "parent_network": { - "type": "LocalTest" - }, - "block_gas_limit": 1000000000, - "initial_state": { - "coins": [ - { - "owner": "0x94ffcc53b892684acefaebc8a3d4a595e528a8cf664eeb3ef36f1020b0809d0d", - "amount": "0xFFFFFFFFFFFFFFFF", - "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" - }, - { - "owner": "0x80d5e88c2b23ec2be6b2e76f3499a1a2755bb2773363785111a719513fb57b8e", - "amount": "0x00000000FFFFFFFF", - "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" - }, - { - "owner": "0xf13c949256d0e119fecaec414ea452f21f9dc1870fb6262ff53b37c32cab4749", - "amount": "0x00000000FFFFFFFF", - "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" - } - ] - }, - "transaction_parameters": { - "contract_max_size": 16777216, - "max_inputs": 255, - "max_outputs": 255, - "max_witnesses": 255, - "max_gas_per_tx": 100000000, - "max_script_length": 1048576, - "max_script_data_length": 1048576, - "max_static_contracts": 255, - "max_storage_slots": 255, - "max_predicate_length": 1048576, - "max_predicate_data_length": 1048576, - "gas_price_factor": 1000000000, - "gas_per_byte": 4, - "max_message_data_length": 1048576 - }, - "block_producer": { - "utxo_validation": true, - "coinbase_recipient": "0x0000000000000000000000000000000000000000000000000000000000000000" - }, - "consensus": { - "PoA": { - "signing_key": "0x22ec92c3105c942a6640bdc4e4907286ec4728e8cfc0d8ac59aad4d8e1ccaefb" - } - } -} +```sh +fuel-core run --chain ./chainConfig.json --db-type in-memory ``` +To find an example chain configuration file for a specific `fuel-core` version, refer to the [`fuel-core`](https://github.com/FuelLabs/fuel-core/tree/master/deployment/scripts/chainspec) repo. + +### Funding a wallet locally + +You can edit the `coins` array inside the `inital_state` object to modify the initial assets owned by a given address. + +The `owner` address must be a `B256` type address (begins with `0x`) instead of a `Bech32` type (begins with `fuel`). + +The `amount` is a hex value. In this example, the value translates to `1,125,899.9 ETH`. + +## Local node (with state persistence) + +This node does persist the blockchain state locally. +To run a local node with persistence a chain configuration file is required. + To start the node, run the following command: ```sh diff --git a/spell-check-custom-words.txt b/spell-check-custom-words.txt index 62413ac5..e34b4d30 100644 --- a/spell-check-custom-words.txt +++ b/spell-check-custom-words.txt @@ -58,4 +58,5 @@ fuelTestnetInlineCode fuelTestnet faucetLink GQLPlaygroundLink -xlarge \ No newline at end of file +xlarge +fuelCoreVersion \ No newline at end of file diff --git a/src/components/MDXRender.tsx b/src/components/MDXRender.tsx index 346dafcc..12c155ba 100644 --- a/src/components/MDXRender.tsx +++ b/src/components/MDXRender.tsx @@ -55,9 +55,15 @@ type MDXRenderProps = { code: string; components: Record; isLatest: boolean; + fuelCoreVersion?: string; }; -export function MDXRender({ code, components, isLatest }: MDXRenderProps) { +export function MDXRender({ + code, + components, + isLatest, + fuelCoreVersion, +}: MDXRenderProps) { const { default: Content } = useMemo( () => runSync(code, { ...runtime, ...provider }), [code] @@ -82,6 +88,7 @@ export function MDXRender({ code, components, isLatest }: MDXRenderProps) { {FUEL_TESTNET} graphQL playground } + fuelCoreVersion={{fuelCoreVersion}} /> ); diff --git a/src/lib/plugins/rehype-code.ts b/src/lib/plugins/rehype-code.ts index 06f51399..26f8dff7 100644 --- a/src/lib/plugins/rehype-code.ts +++ b/src/lib/plugins/rehype-code.ts @@ -180,6 +180,9 @@ function codeLanguage() { if (lang?.includes('sh')) { node.properties.className[0] = 'language-sh'; } + if (lang?.includes('json')) { + node.properties.className[0] = 'language-json'; + } }); }; } diff --git a/src/lib/versions.ts b/src/lib/versions.ts index 6ae3e106..e8622f93 100644 --- a/src/lib/versions.ts +++ b/src/lib/versions.ts @@ -94,6 +94,13 @@ function getIndexerVersion(docsDir: string) { }; } +export function getFuelCoreVersion() { + const filedir = join(DOCS_DIRECTORY, 'fuel-core/Cargo.toml'); + const file = fs.readFileSync(filedir, 'utf-8'); + const tomfile = toml.parse(file); + return tomfile.workspace.package.version; +} + export function getVersions(isLatest: boolean) { const docsDir = isLatest ? LATEST_DOCS_DIRECTORY : DOCS_DIRECTORY; const wallet = getWalletVersion(docsDir); diff --git a/src/pages/[...slug].tsx b/src/pages/[...slug].tsx index 57e69f0a..1c41865d 100644 --- a/src/pages/[...slug].tsx +++ b/src/pages/[...slug].tsx @@ -8,7 +8,7 @@ import { DOCS_DIRECTORY } from '../config/constants'; import useTheme from '../hooks/useTheme'; import { Doc } from '../lib/md-doc'; import { Docs } from '../lib/md-docs'; -import { getVersions } from '../lib/versions'; +import { getFuelCoreVersion, getVersions } from '../lib/versions'; import { DocScreen } from '../screens/DocPage'; import type { DocType, NavOrder, SidebarLinkItem, Versions } from '../types'; @@ -23,6 +23,7 @@ export type DocPageProps = { theme: string; versions: Versions; latestVersions: Versions; + fuelCoreVersion?: string; }; export default function DocPage(props: DocPageProps) { @@ -53,6 +54,11 @@ export const getStaticProps: GetStaticProps = async ({ params }) => { const allLatestNavs = JSON.parse(readFileSync(allLatestNavsPath, 'utf8')); const versions = getVersions(false); const latestVersions = getVersions(true); + let fuelCoreVersion = null; + + if (slug.includes('guides/')) { + fuelCoreVersion = getFuelCoreVersion(); + } return { props: { @@ -65,6 +71,7 @@ export const getStaticProps: GetStaticProps = async ({ params }) => { docLink: doc.navLinks, versions, latestVersions, + fuelCoreVersion, }, }; }; diff --git a/src/screens/DocPage.tsx b/src/screens/DocPage.tsx index b504504b..cdca3ec5 100644 --- a/src/screens/DocPage.tsx +++ b/src/screens/DocPage.tsx @@ -44,6 +44,7 @@ export function DocScreen(props: DocPageProps) { code={props.code} components={components} isLatest={isLatest} + fuelCoreVersion={props.fuelCoreVersion} /> )}