Skip to content

Commit

Permalink
rm state_sim; capella genesis for block_sim (#5331)
Browse files Browse the repository at this point in the history
* rm state_sim; capella genesis for block_sim

* copyright year
  • Loading branch information
tersec authored Aug 21, 2023
1 parent 52640e9 commit 295c3e2
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 472 deletions.
20 changes: 5 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ XML_TEST_BINARIES := \

# test suite
TEST_BINARIES := \
state_sim \
block_sim \
test_libnimbus_lc
.PHONY: $(TEST_BINARIES) $(XML_TEST_BINARIES) force_build_alone_all_tests
Expand Down Expand Up @@ -346,8 +345,8 @@ fork_choice: | build deps
# CI false negatives in a process lasting hours and requiring a restart, and
# therefore even more wasted time, when it does.
#
# If one asks for, e.g., `make all_tests state_sim`, it intentionally allows
# those in paralle, because the CI system does do that.
# If one asks for, e.g., `make all_tests block_sim`, it intentionally allows
# those in parallel, because the CI system doesn't do that.
#
# https://www.gnu.org/software/make/manual/html_node/Parallel-Disable.html
# describes a special target .WAIT which would enable this more easily but
Expand All @@ -367,15 +366,7 @@ all_tests: | build deps nimbus_signing_node force_build_alone_all_tests
$(NIM_PARAMS) $(TEST_MODULES_FLAGS) && \
echo -e $(BUILD_END_MSG) "build/$@"

# State and block sims; getting to 4th epoch triggers consensus checks
state_sim: | build deps
+ echo -e $(BUILD_MSG) "build/$@" && \
MAKE="$(MAKE)" V="$(V)" $(ENV_SCRIPT) scripts/compile_nim_program.sh \
$@ \
"research/$@.nim" \
$(NIM_PARAMS) && \
echo -e $(BUILD_END_MSG) "build/$@"

# Block sim; getting to 4th epoch triggers consensus checks
block_sim: | build deps
+ echo -e $(BUILD_MSG) "build/$@" && \
MAKE="$(MAKE)" V="$(V)" $(ENV_SCRIPT) scripts/compile_nim_program.sh \
Expand Down Expand Up @@ -404,8 +395,7 @@ endif
for TEST_BINARY in $(TEST_BINARIES); do \
PARAMS=""; \
REDIRECT=""; \
if [[ "$${TEST_BINARY}" == "state_sim" ]]; then PARAMS="--validators=8000 --slots=160"; \
elif [[ "$${TEST_BINARY}" == "block_sim" ]]; then PARAMS="--validators=8000 --slots=160"; \
if [[ "$${TEST_BINARY}" == "block_sim" ]]; then PARAMS="--validators=10000 --slots=192"; \
elif [[ "$${TEST_BINARY}" == "test_libnimbus_lc" ]]; then REDIRECT="$${TEST_BINARY}.log"; \
fi; \
echo -e "\nRunning $${TEST_BINARY} $${PARAMS}\n"; \
Expand Down Expand Up @@ -804,7 +794,7 @@ ntu: | build deps
+ $(ENV_SCRIPT) $(NIMC) -d:danger -o:vendor/.nimble/bin/ntu c vendor/nim-testutils/ntu.nim

clean: | clean-common
rm -rf build/{$(TOOLS_CSV),all_tests,test_*,proto_array,fork_choice,*.a,*.so,*_node,*ssz*,nimbus_*,beacon_node*,block_sim,state_sim,transition*,generate_makefile,nimbus-wix/obj}
rm -rf build/{$(TOOLS_CSV),all_tests,test_*,proto_array,fork_choice,*.a,*.so,*_node,*ssz*,nimbus_*,beacon_node*,block_sim,transition*,generate_makefile,nimbus-wix/obj}
ifneq ($(USE_LIBBACKTRACE), 0)
+ "$(MAKE)" -C vendor/nim-libbacktrace clean $(HANDLE_OUTPUT)
endif
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ We provide several tools to interact with ETH2 and the data in the beacon chain:

## For researchers

### State transition simulation
### Block simulation

The state transition simulator can quickly run the Beacon chain state transition function in isolation and output JSON snapshots of the state. The simulation runs without networking and blocks are processed without slot time delays.
The block simulator can quickly run the Beacon chain state transition function in isolation. The simulation runs without networking and without slot time delays.

```bash
# build and run the state simulator, then display its help ("-d:release" speeds it
# build and run the block simulator, then display its help ("-d:release" speeds it
# up substantially, allowing the simulation of longer runs in reasonable time)
make NIMFLAGS="-d:release" state_sim
build/state_sim --help
make NIMFLAGS="-d:release" block_sim
build/block_sim --help
```

### Local network simulation
Expand Down
11 changes: 5 additions & 6 deletions docs/the_nimbus_book/src/developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ nim --version # Nimbus is tested and supported on 1.2.12 at the moment

- build a specific tool:
```bash
make state_sim
make block_sim
```

- you can control the Makefile's verbosity with the V variable (defaults to 0):
Expand Down Expand Up @@ -232,8 +232,8 @@ It runs without networking and blocks are processed without slot time delays.
```bash
# build the state simulator, then display its help ("-d:release" speeds it
# up substantially, allowing the simulation of longer runs in reasonable time)
make NIMFLAGS="-d:release" state_sim
build/state_sim --help
make NIMFLAGS="-d:release" block_sim
build/block_sim --help
```

Use the output of the `help` command to pass desired values to the simulator.
Expand All @@ -244,11 +244,10 @@ The most important options are:
- `slots`: the number of slots to run the simulation for (default 192)
- `validators`: the number of validators (default 6400)
- `attesterRatio`: the expected fraction of attesters that actually do their work for every slot (default 0.73)
- `json_interval`: how often JSON snapshots of the state are outputted (default every 32 slots -- or once per epoch)

For example, to run the state simulator for 384 slots, with 20,000 validators, and an average of 66% of attesters doing their work every slot, while outputting snapshots of the state twice per epoch, run:
For example, to run the block simulator for 384 slots, with 20,000 validators, and an average of 66% of attesters doing their work every slot, run:

```
build/state_sim --slots=384 --validators=20000 --attesterRatio=0.66 --json_interval=16
build/block_sim --slots=384 --validators=20000 --attesterRatio=0.66
```

Loading

0 comments on commit 295c3e2

Please sign in to comment.