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: create network simulator #108

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1b70ae4
create nix scripts, create clap CLI
0xmovses Feb 12, 2024
1024138
move resuable utils into simulator
0xmovses Feb 12, 2024
a580994
fix bug in build.debug for protoc v comparison
0xmovses Feb 12, 2024
a473901
debug
0xmovses Feb 12, 2024
61695f5
update nix deps for macOS target
Feb 13, 2024
1d3d0b1
add nix.flake
Feb 13, 2024
51bf9f9
mv flake.nix
0xmovses Feb 13, 2024
4fd4d35
resolve mac OS
0xmovses Feb 13, 2024
25eb72c
Merge pull request #112 from movemntdev/0xmovses/flake
0xmovses Feb 13, 2024
5fc8fbf
add libcxx and link
0xmovses Feb 14, 2024
38b87be
aarch64
0xmovses Feb 14, 2024
48a5be2
remove pkgs already used by rocksdb
0xmovses Feb 14, 2024
dc9e67d
new flake
0xmovses Feb 14, 2024
9b0a233
update network init, refactors
0xmovses Feb 16, 2024
ad69184
get ava go paths, improve error handling, add log debugs
0xmovses Feb 17, 2024
196fb54
update init logic
0xmovses Feb 17, 2024
59ebfa9
solve avalanchego bin exec bug
0xmovses Feb 18, 2024
0bce357
revert config.toml
0xmovses Feb 18, 2024
6ce4cc2
implement Simulator, refactor, dispatch
0xmovses Feb 19, 2024
aee52e7
updates
0xmovses Feb 19, 2024
31a5d54
cargo.lock
0xmovses Feb 19, 2024
e681064
add validators
0xmovses Feb 20, 2024
cbc005b
add validators
0xmovses Feb 20, 2024
d8f6e0c
Merge pull request #113 from movemntdev/0xmovses/system-deps
0xmovses Feb 20, 2024
90b881a
fix add validator
0xmovses Feb 20, 2024
21c4917
cleanup
0xmovses Feb 20, 2024
1f3daf6
remove unused
0xmovses Feb 20, 2024
dde6bef
remove unused
0xmovses Feb 20, 2024
9cd0cdd
improve get subnet_id & init_log
0xmovses Feb 21, 2024
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
2 changes: 1 addition & 1 deletion m1/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ rustflags = [
"force-unwind-tables=yes",
"-C",
"link-arg=/STACK:8000000" # Set stack to 8 MB
]
]
125 changes: 100 additions & 25 deletions m1/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion m1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ resolver = "2"
members = [
"subnet",
"tests/e2e",
"e2e-benchmark"
"e2e-benchmark",
"simulator",
]

[workspace.package]
Expand Down Expand Up @@ -35,6 +36,7 @@ codespan-reporting = "0.11.1"
criterion = "0.3.5"
criterion-cpu-time = "0.1.0"
dirs = "4.0.0"
env_logger = "0.10.1"
hex = "0.4.3"
hkdf = "0.10.0"
hostname = "0.3.1"
Expand Down
2 changes: 2 additions & 0 deletions m1/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build:
./scripts/build.debug.sh && cargo build -p simuatlor --bin simulator
5 changes: 5 additions & 0 deletions m1/rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
comment_width = 100
format_code_in_doc_comments = true
imports_granularity = "Crate"
imports_layout = "Vertical"
wrap_comments = true
9 changes: 6 additions & 3 deletions m1/scripts/build.debug.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
#!/usr/bin/env bash
set -xue

if ! [[ "$0" =~ scripts/build.debug.sh ]]; then
Expand All @@ -7,8 +8,10 @@ if ! [[ "$0" =~ scripts/build.debug.sh ]]; then
fi

PROTOC_VERSION=$(protoc --version | cut -f2 -d' ')
if [[ "${PROTOC_VERSION}" == "" ]] || [[ "${PROTOC_VERSION}" < 3.15.0 ]]; then
echo "protoc must be installed and the version must be greater than 3.15.0"
MIN_VERSION="3.15"

if ! printf "%s\n%s" "$PROTOC_VERSION" "$MIN_VERSION" | sort -V | tail -n 1 | grep -q "$PROTOC_VERSION"; then
echo "protoc must be installed and the version must be greater than 3.15"
exit 255
fi

Expand All @@ -18,4 +21,4 @@ cargo build -p subnet --bin subnet
./target/debug/subnet --help

./target/debug/subnet genesis "hello world"
./target/debug/subnet vm-id subnet
./target/debug/subnet vm-id subnet
25 changes: 25 additions & 0 deletions m1/scripts/subnet-cli-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash -e

# Install subnet-cli
VERSION=0.0.4 # Populate latest here

GOARCH=$(go env GOARCH)
GOOS=$(go env GOOS)
DOWNLOAD_PATH=/tmp/subnet-cli.tar.gz
DOWNLOAD_URL=https://github.com/ava-labs/subnet-cli/releases/download/v${VERSION}/subnet-cli_${VERSION}_linux_${GOARCH}.tar.gz
if [[ ${GOOS} == "darwin" ]]; then
DOWNLOAD_URL=https://github.com/ava-labs/subnet-cli/releases/download/v${VERSION}/subnet-cli_${VERSION}_darwin_${GOARCH}.tar.gz
fi

rm -f ${DOWNLOAD_PATH}
rm -f /tmp/subnet-cli

echo "downloading subnet-cli ${VERSION} at ${DOWNLOAD_URL}"
curl -L ${DOWNLOAD_URL} -o ${DOWNLOAD_PATH}

echo "extracting downloaded subnet-cli"
tar xzvf ${DOWNLOAD_PATH} -C /tmp

/tmp/subnet-cli -h

cp /tmp/subnet-cli $HOME/bin/subnet-cli
23 changes: 23 additions & 0 deletions m1/simulator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "simulator"
version = "0.1.0"
edition = "2021"

[dependencies]
avalanche-installer = "0.0.77"
avalanche-network-runner-sdk = { git = "https://github.com/0xmovses/avalanche-network-runner-sdk-rs", branch = "main" }
log = "0.4.19"
random-manager = "0.0.5"
serde = { workspace = true }
serde_json = "1.0.108" # https://github.com/serde-rs/json/releases
avalanche-types = { workspace = true } # https://crates.io/crates/avalanche-types
aptos-sdk = {workspace = true }
anyhow = { workspace = true }
env_logger = { workspace = true }
url = { workspace = true }
tokio = { workspace = true }
tonic = "0.9.2"
once_cell = { workspace = true }
rand = { workspace = true }
reqwest = "0.11.24"
clap = { workspace = true }
Loading
Loading