Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@ pgo-data.profdata
**/proof-with-io.json

# Env
.env
.env

# EF test data
script/mainnet/

# Logs and Summaries
**/logs/**
**/summaries/**
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@
"editor.formatOnSave": true,
"editor.hover.enabled": true
},
"rust-analyzer.trace.server": "verbose",
}
79 changes: 60 additions & 19 deletions Cargo.lock

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

23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,35 @@ To run the program without generating a proof:

```sh
cd script
cargo run --release -- --execute
make download
cargo run --release -- --execute --operation_name <OPERATION_NAME>
```

```
possible values for OPERATION_NAME: attestation, attester_slashing, block_header, bls_to_execution_change, deposit, execution_payload, proposer_slashing, sync_aggregate, voluntary_exit, withdrawals
```

This will execute the program and display the output.

### Generate benchmarks for execution

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

```sh
OPERATIONS = attestation attester_slashing block_header bls_to_execution_change deposit execution_payload proposer_slashing sync_aggregate voluntary_exit withdrawals
```

This will execute the program and generate benchmarks (especially for cycles) in `./script/summaries` directory.

### Generate a Core Proof

To generate a core proof for your program:

```sh
cd script
cargo run --release -- --prove
cargo run --release -- --prove --operation_name <OPERATION_NAME>
```
4 changes: 4 additions & 0 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ edition = "2021"
ethereum_ssz = { workspace = true }
snap = "1.1.1"
tracing = { workspace = true }
serde = { version = "1.0.200", default-features = false, features = ["derive"] }

# Ream dependencies
ream-consensus = { workspace = true }
32 changes: 32 additions & 0 deletions lib/src/file.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use std::fs;
use std::path::{Path, PathBuf};

use crate::snappy::decode_snappy;
use crate::ssz::to_ssz;

pub fn read_file<T: ssz::Decode>(path: &Path) -> T {
let raw_bytes =
std::fs::read(path).unwrap_or_else(|e| panic!("Could not read file: {:?}: {}", path, e));
let ssz_bytes = decode_snappy(&raw_bytes).unwrap_or_else(|e| {
panic!("Could not decode snappy {:?}: {}", path, e);
});
to_ssz(&ssz_bytes).unwrap_or_else(|| {
panic!("Could not decode ssz {:?}", path);
})
}

pub fn get_test_cases(base_dir: &PathBuf) -> Vec<String> {
let mut test_cases = Vec::new();

if let Ok(entries) = fs::read_dir(base_dir) {
for entry in entries.flatten() {
if entry.file_type().map(|t| t.is_dir()).unwrap_or(false) {
if let Some(folder_name) = entry.file_name().to_str() {
test_cases.push(folder_name.to_string());
}
}
}
}

test_cases
}
28 changes: 28 additions & 0 deletions lib/src/input.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use ream_consensus::{
attestation::Attestation,
attester_slashing::AttesterSlashing,
bls_to_execution_change::SignedBLSToExecutionChange,
deneb::{
beacon_block::BeaconBlock, beacon_block_body::BeaconBlockBody,
execution_payload::ExecutionPayload,
},
deposit::Deposit,
proposer_slashing::ProposerSlashing,
sync_aggregate::SyncAggregate,
voluntary_exit::SignedVoluntaryExit,
};
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug)]
pub enum OperationInput {
Attestation(Attestation),
AttesterSlashing(AttesterSlashing),
BeaconBlock(BeaconBlock),
SignedBLSToExecutionChange(SignedBLSToExecutionChange),
Deposit(Deposit),
BeaconBlockBody(BeaconBlockBody),
ProposerSlashing(ProposerSlashing),
SyncAggregate(SyncAggregate),
SignedVoluntaryExit(SignedVoluntaryExit),
ExecutionPayload(ExecutionPayload),
}
3 changes: 3 additions & 0 deletions lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
pub mod file;
pub mod input;
pub mod snappy;
pub mod ssz;
8 changes: 2 additions & 6 deletions lib/src/snappy.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
use std::path::Path;

use snap::raw::Decoder;

pub fn read_ssz_snappy<T: ssz::Decode>(path: &Path) -> Option<T> {
let ssz_snappy = std::fs::read(path).ok()?;
pub fn decode_snappy(raw_bytes: &[u8]) -> Result<Vec<u8>, snap::Error> {
let mut decoder = Decoder::new();
let ssz = decoder.decompress_vec(&ssz_snappy).unwrap();
T::from_ssz_bytes(&ssz).ok()
decoder.decompress_vec(raw_bytes)
}
Loading
Loading