Skip to content

Commit

Permalink
Actualize documentation with the latest changes (FuelLabs#1210)
Browse files Browse the repository at this point in the history
  • Loading branch information
xgreenx authored Jun 13, 2023
1 parent 5a54867 commit fcdd1c6
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 40 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ concurrency:

env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.68.2
NIGHTLY_RUST_VERSION: nightly-2022-12-14
RUST_VERSION: 1.69.0
NIGHTLY_RUST_VERSION: nightly-2023-05-23
RUSTFLAGS: -D warnings
REGISTRY: ghcr.io
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
Expand Down
12 changes: 5 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ See the [README.md](README.md#system-requirements) for platform specific setup s

```sh
git clone https://github.com/FuelLabs/fuel-core
cd fuel-core
## Future instructions assume you are in this repository
```

### Configuring your Rust toolchain
Expand All @@ -55,12 +53,12 @@ You can build Fuel Core:
cargo xtask build
```

This command will run `cargo build` and also dump the latest schema into `/assets/` folder.
This command will run `cargo build` and also dump the latest schema into `crates/client/assets/schema.sdl` folder.

Linting is done using rustfmt and clippy, which are each separate commands:

```sh
cargo +nightly fmt --all --check
cargo +nightly fmt --all
```

```sh
Expand All @@ -81,7 +79,7 @@ cargo test --all-targets
For optimal performance, we recommend using native builds. The generated binary will be optimized for your CPU and may contain specific instructions supported only in your hardware.

To build, run:
`$ RUSTFLAGS="-C target-cpu=native" cargo build --release --bin fuel-core`
`$ RUSTFLAGS="-C target-cpu=native" cargo build --release --bin fuel-core-bin`

The generated binary will be located in `./target/release/fuel-core`

Expand All @@ -92,7 +90,7 @@ Using an in-memory (hashmap) based database is supported for testing purposes, s
default features.

```sh
cargo build -p fuel-core --no-default-features
cargo build -p fuel-core-bin --no-default-features
```

## Contribution flow
Expand Down Expand Up @@ -130,7 +128,7 @@ The Client team actively develops and maintains several dependencies used in Fue
- [fuel-merkle](https://github.com/FuelLabs/fuel-vm/tree/master/fuel-merkle)
- [fuel-tx](https://github.com/FuelLabs/fuel-vm/tree/master/fuel-tx)
- [fuel-asm](https://github.com/FuelLabs/fuel-vm/tree/master/fuel-asm)
- [fuel-vm](https://github.com/FuelLabs/fuel-vm)
- [fuel-vm](https://github.com/FuelLabs/fuel-vm/master/fuel-vm)

### Linking issues

Expand Down
145 changes: 125 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,32 @@ Before pushing any changes or creating pull request please run `source ci_checks

## Building

##### System Requirements
### System Requirements

There are several system requirements including clang.

###### MacOS
#### MacOS

```bash
brew update
brew install cmake
brew install protobuf
```

###### Debian
#### Debian

```bash
apt update
apt install -y cmake pkg-config build-essential git clang libclang-dev protobuf-compiler
```

###### Arch
#### Arch

```bash
pacman -Syu --needed --noconfirm cmake gcc pkgconf git clang protobuf-compiler
```

## Building
### Compiling

We recommend using `xtask` to build fuel-core:

Expand All @@ -50,6 +50,21 @@ cargo xtask build

This will run `cargo build` as well as any other custom build processes we have such as re-generating a GraphQL schema for the client.

### Testing

The [ci_checks.sh](ci_checks.sh) script file can be used to run all CI checks,
including the running of tests.

```shell
source ci_checks.sh
```

The script requires pre-installed tools. For more information run:

```shell
cat ci_checks.sh
```

## Running

The service can be launched by executing `fuel-core run`. The list of options for running can be accessed via the `help` option:
Expand All @@ -67,27 +82,30 @@ OPTIONS:
...
```

For many development puposes it is useful to have a state that won't persist and the `db-type` option can be set to `in-memory` as in the following example.
For many development purposes it is useful to have a state that won't persist and the `db-type` option can be set to `in-memory` as in the following example.

#### Example
### Example

```console
$ ./target/debug/fuel-core run --db-type in-memory
Jul 12 23:28:47.238 INFO fuel_core: Binding GraphQL provider to 127.0.0.1:4000
2023-06-13T12:45:22.860536Z INFO fuel_core::cli::run: 230: Block production mode: Instant
2023-06-13T12:38:47.059783Z INFO fuel_core::cli::run: 310: Fuel Core version v0.18.1
2023-06-13T12:38:47.078969Z INFO new{name=fuel-core}:_commit_result{block_id=b1807ca9f2eec7e459b866ecf69b68679fc6b205a9a85c16bd4943d1bfc6fb2a height=0 tx_status=[]}: fuel_core_importer::importer: 231: Committed block
2023-06-13T12:38:47.097777Z INFO new{name=fuel-core}: fuel_core::graphql_api::service: 208: Binding GraphQL provider to 127.0.0.1:4000
```

To disable block production on your local node, set `--poa-instant=false`

#### Example
### Example

```console
$ ./target/debug/fuel-core run --poa-instant=false
2023-01-23T02:25:18.787401Z INFO fuel_core::cli::run: 173: Block production disabled.
2023-06-13T12:44:12.857763Z INFO fuel_core::cli::run: 232: Block production disabled
```

#### Troubleshooting
### Troubleshooting

##### Publishing
#### Publishing

We use [`publish-crates`](https://github.com/katyo/publish-crates) action for automatic publishing of all crates.

Expand All @@ -100,7 +118,7 @@ act release -s GITHUB_TOKEN=<YOUR_GITHUB_TOKEN> -j publish-crates-check --contai
It requires GitHubToken to do request to the GitHub. You can create it
with [this](https://docs.github.com/en/enterprise-server@3.4/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) instruction.

##### Outdated database
#### Outdated database

If you encounter an error such as

Expand All @@ -110,7 +128,7 @@ thread 'main' panicked at 'unable to open database: DatabaseError(Error { messag

Clear your local database using: `rm -rf ~/.fuel/db`

##### File descriptor limits
#### File descriptor limits

On some macOS versions the default file descriptor limit is quite low, which can lead to IO errors with messages like `Too many open files` or even `fatal runtime error: Rust cannot catch foreign exceptions` when RocksDB encounters these issues. Use the following command to increase the open file limit. Note that this only affects the current shell session, so consider adding it to `~/.zshrc`.

Expand Down Expand Up @@ -144,18 +162,18 @@ kubectl delete -f deployment/fuel-core.yml

The client functionality is available through a service endpoint that expect GraphQL queries.

#### Transaction executor
### Transaction executor

The transaction executor currently performs instant block production. Changes are persisted to RocksDB by default.

- Service endpoint: `/graphql`
- Schema (available after building): `fuel-client/assets/schema.sdl`
- Schema (available after building): `crates/client/assets/schema.sdl`

The service expects a mutation defined as `submit` that receives a [Transaction](https://github.com/FuelLabs/fuel-tx) in hex encoded binary format, as [specified here](https://github.com/FuelLabs/fuel-specs/blob/master/specs/protocol/tx_format.md).
The service expects a mutation defined as `submit` that receives a [Transaction](https://github.com/FuelLabs/fuel-vm/tree/master/fuel-tx) in hex encoded binary format, as [specified here](https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/tx_format/transaction.md).

##### cURL example
### cURL example

This example will execute a script that represents the following sequence of [ASM](https://github.com/FuelLabs/fuel-asm):
This example will execute a script that represents the following sequence of [ASM](https://github.com/FuelLabs/fuel-vm/tree/master/fuel-asm):

```rs
ADDI(0x10, RegId::ZERO, 0xca),
Expand All @@ -166,5 +184,92 @@ RET(RegId::ONE),

```console
$ cargo run --bin fuel-core-client -- transaction submit \
"{\"Script\":{\"gas_price\":0,\"gas_limit\":1000000,\"maturity\":0,\"script\":[80,64,0,202,80,68,0,186,51,65,16,0,36,4,0,0],\"script_data\":[],\"inputs\":[],\"outputs\":[],\"witnesses\":[],\"receipts_root\":\"0x6114142d12e0f58cfb8c72c270cd0535944fb1ba763dce83c17e882c482224a2\"}}"
"{\"Script\":{\"gas_price\":0,\"gas_limit\":1000000,\"maturity\":0,\"script\":[80,64,0,202,80,68,0,186,51,65,16,0,36,4,0,0],\"script_data\":[],\"inputs\":[
{
\"CoinSigned\": {
\"utxo_id\": {
\"tx_id\": \"c49d65de61cf04588a764b557d25cc6c6b4bc0d7429227e2a21e61c213b3a3e2\",
\"output_index\": 0
},
\"owner\": \"f1e92c42b90934aa6372e30bc568a326f6e66a1a0288595e6e3fbd392a4f3e6e\",
\"amount\": 10599410012256088338,
\"asset_id\": \"2cafad611543e0265d89f1c2b60d9ebf5d56ad7e23d9827d6b522fd4d6e44bc3\",
\"tx_pointer\": {
\"block_height\": 0,
\"tx_index\": 0
},
\"witness_index\": 0,
\"maturity\": 0,
\"predicate_gas_used\": null,
\"predicate\": null,
\"predicate_data\": null
}
}],\"outputs\":[],\"witnesses\":[{
\"data\": [
150,
31,
98,
51,
6,
239,
255,
243,
45,
35,
182,
26,
129,
152,
46,
95,
45,
211,
114,
58,
51,
64,
129,
194,
97,
14,
181,
70,
190,
37,
106,
223,
170,
174,
221,
230,
87,
239,
67,
224,
100,
137,
25,
249,
193,
14,
184,
195,
15,
85,
156,
82,
91,
78,
91,
80,
126,
168,
215,
170,
139,
48,
19,
5
]
}],\"receipts_root\":\"0x6114142d12e0f58cfb8c72c270cd0535944fb1ba763dce83c17e882c482224a2\"}}"
```
2 changes: 1 addition & 1 deletion bin/fuel-core/src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ impl Command {
}

pub async fn exec(command: Command) -> anyhow::Result<()> {
init_logging().await?;
let config = command.get_config()?;
let network_name = {
#[cfg(feature = "p2p")]
Expand All @@ -325,7 +326,6 @@ pub async fn exec(command: Command) -> anyhow::Result<()> {
#[cfg(not(feature = "p2p"))]
"default_network".to_string()
};
init_logging().await?;
// log fuel-core version
info!("Fuel Core version v{}", env!("CARGO_PKG_VERSION"));
trace!("Initializing in TRACE mode.");
Expand Down
7 changes: 7 additions & 0 deletions ci_checks.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/usr/bin/env bash

# The script runs almost all CI checks locally.
#
# Requires installed:
# - Rust `1.69.0`
# - Nightly rust formatter
# - `cargo install cargo-sort`

cargo +nightly fmt --all -- --check &&
cargo sort -w --check &&
source .github/workflows/scripts/verify_openssl.sh &&
Expand Down
18 changes: 8 additions & 10 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ flowchart TB
APID{{Domain}}
end
BID & BPD --> ES & RS & TXS
SSD --> POAS & P2PS & BIS
SSD --> P2PS & BIS
TXD --> P2PS
POAD --> P2PS & RS & BPS & BIS
APID --> BPS
Expand All @@ -104,13 +104,13 @@ flowchart TB
%% Pink color - Block Producer
linkStyle 3,4,5 fill:none,stroke-width:4px,stroke:pink
%% Green color - Synchronizer
linkStyle 6,7,8 fill:none,stroke-width:4px,stroke:green
linkStyle 6,7 fill:none,stroke-width:4px,stroke:green
%% Blue color - Transaction pool
linkStyle 9 fill:none,stroke-width:4px,stroke:blue
linkStyle 8 fill:none,stroke-width:4px,stroke:blue
%% Orange color - PoA
linkStyle 10,11,12,13 fill:none,stroke-width:4px,stroke:orange
linkStyle 10,11,12,9 fill:none,stroke-width:4px,stroke:orange
%% Purple color - API
linkStyle 14 fill:none,stroke-width:4px,stroke:purple
linkStyle 13 fill:none,stroke-width:4px,stroke:purple
end
```

Expand Down Expand Up @@ -263,11 +263,9 @@ pub enum GossipValidity {
trait BlockImporter {
// commit a sealed block to the chain
async fn commit(block: SealedBlock) -> Result<()>;
}

trait Consensus {
// check with the consensus layer whether a block header passes consensus rules
async fn validate_sealed_block_header(block: SealedBlockHeader) -> Result<()>;

// check with the block importer whether a block header passes consensus rules
async fn validate_sealed_block_header(block: SealedBlockHeader) -> Result<()>;
}

trait Database {
Expand Down

0 comments on commit fcdd1c6

Please sign in to comment.