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
30 changes: 23 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup Rust
uses: dtolnay/rust-toolchain@master
Expand All @@ -45,14 +45,30 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Download test fixtures
env:
GH_TOKEN: ${{ github.token }}
# - name: Download test fixtures
# env:
# GH_TOKEN: ${{ github.token }}
# run: |
# mkdir -p leanSpec/fixtures
# gh run download --repo leanEthereum/leanSpec --name fixtures-prod-scheme --dir leanSpec/fixtures

- name: Checkout leanSpec
uses: actions/checkout@v6
with:
repository: leanEthereum/leanSpec
ref: 050fa4a18881d54d7dc07601fe59e34eb20b9630
path: leanSpec

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Generate test fixtures
working-directory: leanSpec
run: |
mkdir -p leanSpec/fixtures
gh run download --repo leanEthereum/leanSpec --name fixtures-prod-scheme --dir leanSpec/fixtures
uv sync
uv run fill --fork=devnet --clean -n auto

- name: Setup Rust
uses: dtolnay/rust-toolchain@master
Expand Down
134 changes: 60 additions & 74 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ clap = { version = "4.3", features = ["derive", "env"] }
ethereum-types = { version = "0.15.1", features = ["serialize"] }

# XMSS signatures
leansig = { git = "https://github.com/leanEthereum/leansig.git", rev = "ae12a5feb25d917c42b6466444ebd56ec115a629" }
leansig = { git = "https://github.com/leanEthereum/leansig.git", rev = "f10dcbe" }

# SSZ deps
# TODO: roll up our own implementation
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ test: ## 🧪 Run all tests, then forkchoice tests with skip-signature-verificat
cargo test -p ethlambda-blockchain --features skip-signature-verification --test forkchoice_spectests

docker-build: ## 🐳 Build the Docker image
docker build -t ethlambda:latest .
docker build -t ghcr.io/lambdaclass/ethlambda:local .

LEAN_SPEC_COMMIT_HASH:=fbbacbea4545be870e25e3c00a90fc69e019c5bb
LEAN_SPEC_COMMIT_HASH:=050fa4a18881d54d7dc07601fe59e34eb20b9630

leanSpec:
git clone https://github.com/leanEthereum/leanSpec.git --single-branch
cd leanSpec && git checkout $(LEAN_SPEC_COMMIT_HASH)

leanSpec/fixtures: leanSpec
cd leanSpec && uv run fill --fork devnet --scheme=prod -o fixtures
cd leanSpec && uv run fill --fork devnet -o fixtures #--scheme=prod

# lean-quickstart:
# git clone https://github.com/blockblaz/lean-quickstart.git --depth 1 --single-branch
Expand Down
5 changes: 0 additions & 5 deletions crates/blockchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,3 @@ name = "forkchoice_spectests"
path = "tests/forkchoice_spectests.rs"
harness = false
required-features = ["skip-signature-verification"]

[[test]]
name = "signature_spectests"
path = "tests/signature_spectests.rs"
harness = false
23 changes: 16 additions & 7 deletions crates/blockchain/src/key_manager.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::collections::HashMap;

use ethlambda_types::{
attestation::XmssSignature,
primitives::H256,
attestation::{Attestation, XmssSignature},
primitives::{H256, TreeHash},
signature::{ValidatorSecretKey, ValidatorSignature},
};

Expand Down Expand Up @@ -51,7 +51,7 @@ impl KeyManager {
self.keys.keys().copied().collect()
}

/// Signs an attestation message for the specified validator.
/// Signs a message for the specified validator.
///
/// # Arguments
///
Expand All @@ -68,13 +68,13 @@ impl KeyManager {
/// # Example
///
/// ```ignore
/// let signature = key_manager.sign_attestation(
/// let signature = key_manager.sign_message(
/// validator_id,
/// epoch,
/// &message_hash
/// )?;
/// ```
pub fn sign_attestation(
fn sign_message(
&mut self,
validator_id: u64,
epoch: u32,
Expand All @@ -96,6 +96,15 @@ impl KeyManager {

Ok(xmss_sig)
}

pub fn sign_attestation(
&mut self,
attestation: &Attestation,
) -> Result<XmssSignature, KeyManagerError> {
let message_hash = attestation.tree_hash_root();
let epoch = attestation.data.slot as u32;
self.sign_message(attestation.validator_id, epoch, &message_hash)
}
}

#[cfg(test)]
Expand All @@ -110,12 +119,12 @@ mod tests {
}

#[test]
fn test_sign_attestation_validator_not_found() {
fn test_sign_message_validator_not_found() {
let keys = HashMap::new();
let mut key_manager = KeyManager::new(keys);
let message = H256::default();

let result = key_manager.sign_attestation(123, 0, &message);
let result = key_manager.sign_message(123, 0, &message);
assert!(matches!(
result,
Err(KeyManagerError::ValidatorKeyNotFound(123))
Expand Down
Loading