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

feat: create network simulator #108

wants to merge 29 commits into from

Conversation

0xmovses
Copy link
Collaborator

@0xmovses 0xmovses commented Feb 12, 2024

Changes made

  • Created a new simulator crate that will enable us to simulate asynchronous network conditions with more degrees of control. We can use this crate to build out further e2e tests also.

  • I had to fork the anr-rs-sdk, as the avalanche-maintained rust client did not support the RPC calls we needed. I made several commits there, updating the rpc.proto file and adding new client methods.

System Deps

NB: These will be managed by the nix dev environment. But for now, when running locally it's critical to have avalanchego installed specifically v.1.10.12.

Pre-reqs

avalanchego binary needs to be in ~/.mvmt/avalanchego/build`, the ANR running in the simulator looks for it at that path. (We can change this path to wherever it will be in the nix shell).

Because the plugin version supported is 28. Any versions higher than this will not work with our vm-plugin subnet. Lower versions are possible, but I went with the latest, working version.

Testing steps

  1. create the subnet
cargo build -p subnet --bin subnet
./target/debug/subnet genesis "hello world"
./target/debug/subnet vm-id subnet
  1. Run the network-runner
avalanche-network-runner server \
--log-level debug \
--port=":12342" \
--disable-grpc-gateway 
  1. Build the simulator cd m1/simulator && cargo build
  2. Start the simulator (default nodes amount, 5) cargo run start --verbose, or cargo start --nodes 5
  3. cargo add-validator --name node1
  4. cargo remove-validator --name node 1
  5. cargo add-node --name node6
  6. cargo remove-node --name node6

Further Considerations

I ran into an interesting issue to do with avalanchego versions and our vm-plugin version. Our subnet runs vm-plugin version 28 , the latest avalanchego version that can run our subnet is v1.10.12

We have scripts to help with installation, but they have to be run in particular orders, also there are different scripts directories at different places in our workspace. Until we have the nix-shell running with all the deps needed. I could put together a doc for onboarding any devs that are going to be working on the m1 repo, as there are a few system-deps needed and understanding around how we use them, with avalanche-network-runner, for example.

Although, it does seem like nix-shell will be runnable soon, so maybe this doc not needed as that will alleviate all pain points here. I'd say this work around the nix-shell / system- dependencies and dev-ex is separate to the simulator.

@0xmovses 0xmovses marked this pull request as draft February 12, 2024 16:37
@0xmovses 0xmovses added enhancement New feature or request tooling Ask for improvements to tooling testing Additions to tests big a diff of 800+ lines labels Feb 17, 2024
@0xmovses 0xmovses linked an issue Feb 19, 2024 that may be closed by this pull request
@0xmovses 0xmovses self-assigned this Feb 20, 2024
@0xmovses 0xmovses marked this pull request as ready for review February 20, 2024 18:53
@0xmovses 0xmovses changed the title feat: create network simulator [WIP] feat: create network simulator Feb 20, 2024
@0xmovses 0xmovses removed the big a diff of 800+ lines label Feb 21, 2024
@l-monninger
Copy link
Collaborator

I'd like to Move this into https://github.com/movementlabsxyz/sdk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request testing Additions to tests tooling Ask for improvements to tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: add simulation suite for M1 subnet
2 participants