Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
1,440 changes: 943 additions & 497 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["host", "lib", "methods"]
members = ["host", "lib", "methods", "methods/guest"]
resolver = "2"

# Always optimize; building and running the guest takes much longer without optimization.
Expand All @@ -14,12 +14,16 @@ lto = true
edition = "2024"

[workspace.dependencies]
ethereum_hashing = { git = "https://github.com/ReamLabs/ethereum_hashing" }
ethereum_ssz = "0.9"
ream-consensus = { git = "https://github.com/ReamLabs/ream.git", package = "ream-consensus", features = ["zkvm"] }
ream-consensus = { git = "https://github.com/ReamLabs/ream.git", package = "ream-consensus-beacon", features = ["zkvm"] }
sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.8-risczero.0" }
Copy link
Member

Choose a reason for hiding this comment

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

Do we use sha2 here? Deletting this dependency doesn't make any trouble in my local environment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was introduced by @SuccinctPaul for benchmarks using this precompile. It significantly reduces the execution cycles and time. From cargo.lock, it seems sha2 is being used extensively by several packages.
If we delete this dependency it would switch to the original sha2 crate and the timings almost double.

Copy link
Contributor

Choose a reason for hiding this comment

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

yep.

ssz_types = { git = "https://github.com/ReamLabs/ssz_types", branch = "magic-extended-list" }
tracing = "0.1"
tree_hash = "0.10"
tree_hash_derive = "0.10"

[patch.crates-io]
ethereum_hashing = { git = "https://github.com/ReamLabs/ethereum_hashing" }
sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.8-risczero.0" }
ssz_types = { git = "https://github.com/ReamLabs/ssz_types", branch = "magic-extended-list" } # Extends 2^29 to 2^40 list root
61 changes: 58 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,69 @@

### Generate benchmarks

First, download the required test data:

```sh
cd host
make download
make run-<OPERATION_NAME>
```

Then, run benchmarks for specific operations:

#### Block Operations
Run a specific block operation:
```sh
make run-block-<OPERATION_NAME>
```

Available block operations:
- attestation
- attester_slashing
- block_header
- bls_to_execution_change
- deposit
- execution_payload (not implemented)
- proposer_slashing
- sync_aggregate
- voluntary_exit
- withdrawals (incompatible with BeaconState workaround)
Run all block operations:
```sh
make block-all
```

#### Epoch Operations
Run a specific epoch processing operation:
```sh
make run-epoch-<OPERATION_NAME>
```

Available epoch operations:
- justification_and_finalization
- inactivity_updates
- rewards_and_penalties
- registry_updates
- slashings
- eth1_data_reset
- pending_deposits
- pending_consolidations
- effective_balance_updates
- slashings_reset
- randao_mixes_reset
- historical_summaries_update
- participation_flag_updates

Run all epoch operations:
```sh
make epoch-all
```

#### Run All Executable Operations
Run all operations that can be executed (excludes execution_payload and withdrawals from block operations):
```sh
OPERATIONS = attestation attester_slashing block_header bls_to_execution_change deposit execution_payload proposer_slashing sync_aggregate voluntary_exit withdrawals
make all
```

This will execute the program and generate benchmarks (especially for cycles) in `./host/summaries` directory.
### Output
- Logs are saved in `./host/logs/`
- Benchmark summaries (including cycle counts) are generated in `./host/summaries/`
2 changes: 1 addition & 1 deletion host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ derive_more = { version = "2.0.1", features = ["full"] }
dotenv = "0.15.0"
hex = "0.4.3"
methods = { path = "../methods" }
risc0-zkvm = { version = "2.0.1" }
risc0-zkvm = { version = "3.0.3" }
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = { version = "1.0.139", default-features = false, features = ["alloc"] }
tracing = { workspace = true }
Expand Down
50 changes: 37 additions & 13 deletions host/Makefile
Copy link
Member

Choose a reason for hiding this comment

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

I guess these changes should be also applied to the README.md in the project root.

Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,63 @@ DOWNLOAD_SCRIPT = ./subscripts/download_ef_data.sh
PARSE_SCRIPT = ./subscripts/parse_log_to_table.sh
SORT_SCRIPT = ./subscripts/sort_table.sh

OPERATIONS = attestation attester_slashing block_header bls_to_execution_change deposit execution_payload proposer_slashing sync_aggregate voluntary_exit withdrawals
BLOCK_OPERATIONS = attestation attester_slashing block_header bls_to_execution_change deposit execution_payload proposer_slashing sync_aggregate voluntary_exit withdrawals
EPOCH_OPERATIONS = justification_and_finalization inactivity_updates rewards_and_penalties registry_updates slashings eth1_data_reset pending_deposits pending_consolidations effective_balance_updates slashings_reset randao_mixes_reset historical_summaries_update participation_flag_updates

RISC0_DEV_MODE = 1
RUST_BACKTRACE = 0
RUST_BACKTRACE = full

.PHONY: all download run clean $(addprefix run-, $(OPERATIONS))
.PHONY: all download run clean $(addprefix run-block-, $(BLOCK_OPERATIONS)) $(addprefix run-epoch-, $(EPOCH_OPERATIONS)) block-all epoch-all

# run-execution_payload (not implemented) and run-withdrawals (incompatible with BeaconState workaround) are excluded
all: download run-attestation run-attester_slashing run-block_header run-bls_to_execution_change run-deposit run-proposer_slashing run-sync_aggregate run-voluntary_exit
# run-block-execution_payload (not implemented) and run-block-withdrawals (incompatible with BeaconState workaround) are excluded
all: download $(addprefix run-block-, $(filter-out execution_payload withdrawals, $(BLOCK_OPERATIONS))) $(addprefix run-epoch-, $(EPOCH_OPERATIONS))

# Run all block processing benchmarks
block-all: $(addprefix run-block-, $(BLOCK_OPERATIONS))

# Run all epoch processing benchmarks
epoch-all: $(addprefix run-epoch-, $(EPOCH_OPERATIONS))

download:
@echo "Running download script..."
@chmod +x $(DOWNLOAD_SCRIPT)
@$(DOWNLOAD_SCRIPT)

run:
@echo "Specify an operation: $(OPERATIONS)"
@echo "Specify a block operation: $(BLOCK_OPERATIONS)"
@echo "Specify an epoch operation: $(EPOCH_OPERATIONS)"
@echo "Use: make run-block-<operation> or make run-epoch-<operation>"
@exit 1

$(addprefix run-, $(OPERATIONS)): run-%: $(EXTRACT_DIR)
$(addprefix run-block-, $(BLOCK_OPERATIONS)): run-block-%: $(EXTRACT_DIR)
@mkdir -p $(LOGS_DIR)
@mkdir -p $(SUMMARIES_DIR)
@echo "##################################################"
@echo "Running benchmarks for $*..."
@echo "Running block benchmarks for $*..."
@echo "##################################################"
@NO_COLOR=1 RISC0_DEV_MODE=$(RISC0_DEV_MODE) RUST_BACKTRACE=$(RUST_BACKTRACE) \
cargo run --release -- -o $* \
cargo run --release -- \
--excluded-cases multi_proposer_index_iterations \
--excluded-cases random_with_exits_with_duplicates \
2>&1 | tee $(LOGS_DIR)/execution_$*.log
@echo "Execution complete for $*."
@$(PARSE_SCRIPT) $*
@$(SORT_SCRIPT) $(SUMMARIES_DIR)/summary_$*.md
block $* \
2>&1 | tee $(LOGS_DIR)/execution_block_$*.log
@echo "Execution complete for block $*."
@$(PARSE_SCRIPT) block_$*
@$(SORT_SCRIPT) $(SUMMARIES_DIR)/summary_block_$*.md

$(addprefix run-epoch-, $(EPOCH_OPERATIONS)): run-epoch-%: $(EXTRACT_DIR)
@mkdir -p $(LOGS_DIR)
@mkdir -p $(SUMMARIES_DIR)
@echo "##################################################"
@echo "Running epoch processing benchmarks for $*..."
@echo "##################################################"
@NO_COLOR=1 RISC0_DEV_MODE=$(RISC0_DEV_MODE) RUST_BACKTRACE=$(RUST_BACKTRACE) \
cargo run --release -- \
epoch $* \
2>&1 | tee $(LOGS_DIR)/execution_epoch_$*.log
@echo "Execution complete for epoch $*."
@$(PARSE_SCRIPT) epoch_$*
@$(SORT_SCRIPT) $(SUMMARIES_DIR)/summary_epoch_$*.md

clean:
@echo "Cleaning up downloaded/execution files..."
Expand Down
Loading
Loading