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

Enable Running Validator As Process & Container #1437

Merged
merged 3 commits into from
Apr 19, 2022
Merged

Conversation

oxade
Copy link
Contributor

@oxade oxade commented Apr 19, 2022

Allows one to start a validator with a genesis config.
This allows running validators in containers as long as we provide:

  1. Genesis config file
  2. sui_programmability dir for genesis objects
  3. The address of the validator to run

We simply need to provide these with the docker file.

Note:

  1. For now we don't care about sharing the authority keys because it's all internal for devnet.
  2. Once this PR merges, I'll add the Dockerfile

Example below:

mbp> ./validator --genesis-config-path ../../genesis.json --address 672CE5B4B59F378ADB393B435D04B816C99C0CB8
2022-04-19T03:13:01.552052Z  INFO sui::sui_commands: Creating 2 new authorities...
2022-04-19T03:13:01.552111Z  INFO sui::sui_commands: Creating accounts and gas objects...
2022-04-19T03:13:01.552154Z  INFO sui::sui_commands: Loading Move framework lib from "/Users/ade/Documents/work/val/fastx/sui_programmability/framework/deps/move-stdlib"
2022-04-19T03:13:01.559264Z  INFO sui::sui_commands: Loading Sui framework lib from "/Users/ade/Documents/work/val/fastx/sui_programmability/framework"
2022-04-19T03:13:01.605967Z  INFO validator: Started 672CE5B4B59F378ADB393B435D04B816C99C0CB8 authority on 127.0.0.1:5000
2022-04-19T03:13:01.616715Z  INFO sui_network::transport: Listening to TCP traffic on 127.0.0.1:5000

With the following config file: genesis.json

{
  "authorities": [
    {
      "key_pair": "gpQYaPZzWoi0tLUuu6CC3XO291OAUIzkwQVJ0XAhvWQ06QN5OysR6AZvmebhnKTD0wIAAKXfJjlUOaKZFIiMgA==",
      "host": "127.0.0.1",
      "port": 5000,
      "db_path": "DB_PATH1",
      "stake": 3
    },
    {
      "key_pair": "WwFNQ+z4cKJ3vV4XkQx9v9pSLhTBQ6LeknR6MwfXo2OWwXXe4YF3ED6b8cByM1OZCl9BQjW9aNe7A7qHsedKGw==",
      "host": "127.0.0.1",
      "port": 5001,
      "db_path": "DB_PATH2",
      "stake": 6
    }
  ],
  "sui_framework_lib_path": "../../sui_programmability/framework",
  "move_framework_lib_path": "../../sui_programmability/framework/deps/move-stdlib",
  "accounts": [
    {
      "address": "09818AAC3EDF9CF9B006B70C36E7241768B26386",
      "gas_objects": [
        {
          "object_id": "0000000000000000000000000070000000000127",
          "gas_value": 1000000000
        },
        {
          "object_id": "0000000000000000000000000070000000000128",
          "gas_value": 1000000
        }
      ]
    }
  ]
}

Sample Dockerfile

FROM ubuntu:focal

RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata

RUN apt-get install -y git curl build-essential

RUN apt-get install -y libssl-dev
RUN apt-get install -y pkg-config
RUN apt-get install -y libclang-dev

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

WORKDIR build

RUN git clone https://github.com/MystenLabs/sui.git
WORKDIR sui
RUN git checkout validator_as_process

ENV PATH="/root/.cargo/bin:${PATH}"

RUN cargo build --release 

# Copy the config
COPY genesis.json target/release/
WORKDIR target/release

CMD ./validator --genesis-config-path genesis.json --address {VALIDATOR_ADDRESS}

Thanks @mystenmark for initial dockerfile

@oxade oxade changed the title Added validator as separate binary Allow Running Validator As Process Apr 19, 2022
@codecov
Copy link

codecov bot commented Apr 19, 2022

Codecov Report

Merging #1437 (106095b) into main (72dbf0b) will decrease coverage by 0.29%.
The diff coverage is 10.60%.

@@            Coverage Diff             @@
##             main    #1437      +/-   ##
==========================================
- Coverage   82.45%   82.15%   -0.30%     
==========================================
  Files         103      104       +1     
  Lines       21069    21132      +63     
==========================================
- Hits        17373    17362      -11     
- Misses       3696     3770      +74     
Impacted Files Coverage Δ
sui/src/unit_tests/cli_tests.rs 89.52% <ø> (ø)
sui/src/validator.rs 2.00% <2.00%> (ø)
sui/src/config.rs 82.55% <11.11%> (-4.69%) ⬇️
sui/src/sui_commands.rs 75.83% <71.42%> (-0.28%) ⬇️
sui_core/src/safe_client.rs 77.31% <0.00%> (-2.53%) ⬇️
sui_core/src/authority_aggregator.rs 86.71% <0.00%> (-1.33%) ⬇️
sui_core/src/authority/temporary_store.rs 83.92% <0.00%> (-0.40%) ⬇️
sui/src/wallet_commands.rs 79.75% <0.00%> (+0.20%) ⬆️
...i_programmability/verifier/src/id_leak_verifier.rs 91.03% <0.00%> (+0.44%) ⬆️
network_utils/src/unit_tests/transport_tests.rs 89.70% <0.00%> (+1.47%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 72dbf0b...106095b. Read the comment docs.

@oxade oxade changed the title Allow Running Validator As Process Allow Running Validator As Process & Container Apr 19, 2022
@oxade oxade changed the title Allow Running Validator As Process & Container Enable Running Validator As Process & Container Apr 19, 2022
..Default::default()
};
#[allow(unused)]
let guard = telemetry_subscribers::init(config);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just do let _guard = instead of #[allow(unused)]

@mystenmark
Copy link
Contributor

This looks perfect for what we need right now! Thanks!

@oxade oxade merged commit 6043b96 into main Apr 19, 2022
@oxade oxade deleted the validator_as_process branch April 19, 2022 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants