<commit_before>---
title: "Run Validator Node Using Source Code"
slug: "run-validator-node-using-source"
sidebar_position: 13
---

# Using Aptos-core source code

1. Clone the Aptos repo.

      ```
      git clone https://github.com/<YOUR-GITHUB-USERID>/aptos-core

      ```

2. `cd` into `aptos-core` directory.

    ```
    cd aptos-core
    ```

3. Run the `scripts/dev_setup.sh` Bash script as shown below. This will prepare your developer environment.

    ```
    ./scripts/dev_setup.sh
    ```

4. Update your current shell environment.

    ```
    source ~/.cargo/env
    ```

With your development environment ready, now you can start to setup your Validator node.

5. Checkout the `testnet` branch using `git checkout --track origin/testnet`.

6. Create a directory for your Aptos node composition. e.g.
    ```
    export WORKSPACE=testnet
    mkdir ~/$WORKSPACE
    ```

7. Generate key pairs (node owner key, consensus key and networking key) in your working directory.

    ```
    cargo run --release -p aptos -- genesis generate-keys --output-dir ~/$WORKSPACE
    ```

    This will create three files: `private-keys.yaml`, `validator-identity.yaml`, `validator-full-node-identity.yaml` for you. **IMPORTANT**: Backup your key files somewhere safe. These key files are important for you to establish ownership of your node, and you will use this information to claim your rewards later if eligible. Never share those keys with anyone else.

8. Configure validator information, you need to setup a static IP / DNS address which can be used by the node, and make sure the network / firewalls are properly configured to accept external connections. This is all the info you need to register on our community website later.

    ```
    cargo run --release -p aptos -- genesis set-validator-configuration \
        --keys-dir ~/$WORKSPACE --local-repository-dir ~/$WORKSPACE \
        --username <pick a username for your node> \
        --validator-host <Validator Node IP / DNS address>:<Port> \
        --full-node-host <Full Node IP / DNS address>:<Port>

    # for example, with IP:

    cargo run --release -p aptos -- genesis set-validator-configuration \
        --keys-dir ~/$WORKSPACE --local-repository-dir ~/$WORKSPACE \
        --username aptosbot \
        --validator-host 172.16.17.32:6180 \
        --full-node-host 192.168.3.11:6182

    # for example, with DNS:

    cargo run --release -p aptos -- genesis set-validator-configuration \
        --keys-dir ~/$WORKSPACE --local-repository-dir ~/$WORKSPACE \
        --username aptosbot \
        --validator-host bot.aptosdev.com:6180 \
        --full-node-host fn.bot.aptosdev.com:6182
    ```

    This will create a YAML file in your working directory with your username, e.g. `aptosbot.yml`, it should looks like:

    ```
    ---
    account_address: 7410973313fd0b5c69560fd8cd9c4aaeef873f869d292d1bb94b1872e737d64f
    consensus_key: "<KEY>"
    account_key: "0x83f090aee4525052f3b504805c2a0b1d37553d611129289ede2fc9ca5f6aed3c"
    network_key: "0xa06381a17b090b8db5ffef97c6e861baad94a1b0e3210e6309de84c15337811d"
    validator_host:
      host: 172.16.17.32
      port: 6180
    full_node_host:
      host: 192.168.3.11
      port: 6182
    stake_amount: 1
    ```

9. Create layout YAML file, which defines the node in the validatorSet, for test mode, we can create a genesis blob containing only one node.

    ```
    vi ~/$WORKSPACE/layout.yaml
    ```

    Add the public key for root account, node username, and chain_id in the `layout.yaml` file, for example:

    ```
    ---
    root_key: "<KEY>"
    users:
      - <username you created in step 8>
    chain_id: 23
    ```

    You can use the same root key as the example, or generate new one yourself by running `cargo run -p aptos -- key generate --output-file <file name>`

10. Build AptosFramework Move bytecodes, copy into the framework folder

    ```
    cargo run --release --package framework -- --package aptos-framework --output current

    mkdir ~/WORKSPACE/framework

    mv aptos-framework/releases/artifacts/current/build/**/bytecode_modules/*.mv ~/$WORKSPACE/framework/
    ```

    You should now have a folder called `framework`, which contains move bytecodes with format `.mv`.
<commit_msg>[Documentation] Fix typo in using-source-code.md (#1010)<commit_after>---
title: "Run Validator Node Using Source Code"
slug: "run-validator-node-using-source"
sidebar_position: 13
---

# Using Aptos-core source code

1. Clone the Aptos repo.

      ```
      git clone https://github.com/<YOUR-GITHUB-USERID>/aptos-core

      ```

2. `cd` into `aptos-core` directory.

    ```
    cd aptos-core
    ```

3. Run the `scripts/dev_setup.sh` Bash script as shown below. This will prepare your developer environment.

    ```
    ./scripts/dev_setup.sh
    ```

4. Update your current shell environment.

    ```
    source ~/.cargo/env
    ```

With your development environment ready, now you can start to setup your Validator node.

5. Checkout the `testnet` branch using `git checkout --track origin/testnet`.

6. Create a directory for your Aptos node composition. e.g.
    ```
    export WORKSPACE=testnet
    mkdir ~/$WORKSPACE
    ```

7. Generate key pairs (node owner key, consensus key and networking key) in your working directory.

    ```
    cargo run --release -p aptos -- genesis generate-keys --output-dir ~/$WORKSPACE
    ```

    This will create three files: `private-keys.yaml`, `validator-identity.yaml`, `validator-full-node-identity.yaml` for you. **IMPORTANT**: Backup your key files somewhere safe. These key files are important for you to establish ownership of your node, and you will use this information to claim your rewards later if eligible. Never share those keys with anyone else.

8. Configure validator information, you need to setup a static IP / DNS address which can be used by the node, and make sure the network / firewalls are properly configured to accept external connections. This is all the info you need to register on our community website later.

    ```
    cargo run --release -p aptos -- genesis set-validator-configuration \
        --keys-dir ~/$WORKSPACE --local-repository-dir ~/$WORKSPACE \
        --username <pick a username for your node> \
        --validator-host <Validator Node IP / DNS address>:<Port> \
        --full-node-host <Full Node IP / DNS address>:<Port>

    # for example, with IP:

    cargo run --release -p aptos -- genesis set-validator-configuration \
        --keys-dir ~/$WORKSPACE --local-repository-dir ~/$WORKSPACE \
        --username aptosbot \
        --validator-host 172.16.17.32:6180 \
        --full-node-host 192.168.3.11:6182

    # for example, with DNS:

    cargo run --release -p aptos -- genesis set-validator-configuration \
        --keys-dir ~/$WORKSPACE --local-repository-dir ~/$WORKSPACE \
        --username aptosbot \
        --validator-host bot.aptosdev.com:6180 \
        --full-node-host fn.bot.aptosdev.com:6182
    ```

    This will create a YAML file in your working directory with your username, e.g. `aptosbot.yml`, it should looks like:

    ```
    ---
    account_address: 7410973313fd0b5c69560fd8cd9c4aaeef873f869d292d1bb94b1872e737d64f
    consensus_key: "<KEY>"
    account_key: "0x83f090aee4525052f3b504805c2a0b1d37553d611129289ede2fc9ca5f6aed3c"
    network_key: "0xa06381a17b090b8db5ffef97c6e861baad94a1b0e3210e6309de84c15337811d"
    validator_host:
      host: 172.16.17.32
      port: 6180
    full_node_host:
      host: 192.168.3.11
      port: 6182
    stake_amount: 1
    ```

9. Create layout YAML file, which defines the node in the validatorSet, for test mode, we can create a genesis blob containing only one node.

    ```
    vi ~/$WORKSPACE/layout.yaml
    ```

    Add the public key for root account, node username, and chain_id in the `layout.yaml` file, for example:

    ```
    ---
    root_key: "0x5243ca72b0766d9e9cbf2debf6153443b01a1e0e6d086c7ea206eaf6f8043956"
    users:
      - <username you created in step 8>
    chain_id: 23
    ```

    You can use the same root key as the example, or generate new one yourself by running `cargo run -p aptos -- key generate --output-file <file name>`

10. Build AptosFramework Move bytecodes, copy into the framework folder

    ```
    cargo run --release --package framework -- --package aptos-framework --output current

    mkdir ~/$WORKSPACE/framework

    mv aptos-framework/releases/artifacts/current/build/**/bytecode_modules/*.mv ~/$WORKSPACE/framework/
    ```

    You should now have a folder called `framework`, which contains move bytecodes with format `.mv`.

{'fraction_non_alphanumeric': 0.10443955024921757, 'fraction_numerical': 0.05181407209922337, 'mean_word_length': 2.843207126948775, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 8, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1117086', 'n_tokens_mistral': 2913, 'n_tokens_neox': 2663, 'n_words': 897}