Skip to content

Commit 959f89c

Browse files
authored
feat: add support for devnet 1 (#40)
* chore: pin leanSig to f10dcbe * fix: add missing checks in validate_attestation * fix: change image name in make docker-build * chore: update sample gossiped block * chore: pin leanSpec@050fa4a * chore: comment out --scheme flag when generating fixtures * fix: move to unaggregated signatures * chore: remove signature spectests * refactor: unify gossiped and block attestation signatures field * test: update fork choice test runner * fix: move to unaggregated attestations for gossipsub * fix: skip failing test with wrong labels * fix: sign Attestation instead of AttestationData * fix: use attestation instead of data when verifying * fix: process blocks when proposing * chore: use local tag for docker image * chore: fmt * ci: generate old version fixtures
1 parent 62d1258 commit 959f89c

File tree

19 files changed

+380
-1116
lines changed

19 files changed

+380
-1116
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
name: Lint
2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/checkout@v4
24+
- uses: actions/checkout@v6
2525

2626
- name: Setup Rust
2727
uses: dtolnay/rust-toolchain@master
@@ -45,14 +45,30 @@ jobs:
4545
name: Test
4646
runs-on: ubuntu-latest
4747
steps:
48-
- uses: actions/checkout@v4
48+
- uses: actions/checkout@v6
4949

50-
- name: Download test fixtures
51-
env:
52-
GH_TOKEN: ${{ github.token }}
50+
# - name: Download test fixtures
51+
# env:
52+
# GH_TOKEN: ${{ github.token }}
53+
# run: |
54+
# mkdir -p leanSpec/fixtures
55+
# gh run download --repo leanEthereum/leanSpec --name fixtures-prod-scheme --dir leanSpec/fixtures
56+
57+
- name: Checkout leanSpec
58+
uses: actions/checkout@v6
59+
with:
60+
repository: leanEthereum/leanSpec
61+
ref: 050fa4a18881d54d7dc07601fe59e34eb20b9630
62+
path: leanSpec
63+
64+
- name: Install uv
65+
uses: astral-sh/setup-uv@v7
66+
67+
- name: Generate test fixtures
68+
working-directory: leanSpec
5369
run: |
54-
mkdir -p leanSpec/fixtures
55-
gh run download --repo leanEthereum/leanSpec --name fixtures-prod-scheme --dir leanSpec/fixtures
70+
uv sync
71+
uv run fill --fork=devnet --clean -n auto
5672
5773
- name: Setup Rust
5874
uses: dtolnay/rust-toolchain@master

Cargo.lock

Lines changed: 60 additions & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ clap = { version = "4.3", features = ["derive", "env"] }
5252
ethereum-types = { version = "0.15.1", features = ["serialize"] }
5353

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

5757
# SSZ deps
5858
# TODO: roll up our own implementation

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ test: ## 🧪 Run all tests, then forkchoice tests with skip-signature-verificat
1111
cargo test -p ethlambda-blockchain --features skip-signature-verification --test forkchoice_spectests
1212

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

16-
LEAN_SPEC_COMMIT_HASH:=fbbacbea4545be870e25e3c00a90fc69e019c5bb
16+
LEAN_SPEC_COMMIT_HASH:=050fa4a18881d54d7dc07601fe59e34eb20b9630
1717

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

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

2525
# lean-quickstart:
2626
# git clone https://github.com/blockblaz/lean-quickstart.git --depth 1 --single-branch

crates/blockchain/Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,3 @@ name = "forkchoice_spectests"
4545
path = "tests/forkchoice_spectests.rs"
4646
harness = false
4747
required-features = ["skip-signature-verification"]
48-
49-
[[test]]
50-
name = "signature_spectests"
51-
path = "tests/signature_spectests.rs"
52-
harness = false

crates/blockchain/src/key_manager.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::collections::HashMap;
22

33
use ethlambda_types::{
4-
attestation::XmssSignature,
5-
primitives::H256,
4+
attestation::{Attestation, XmssSignature},
5+
primitives::{H256, TreeHash},
66
signature::{ValidatorSecretKey, ValidatorSignature},
77
};
88

@@ -51,7 +51,7 @@ impl KeyManager {
5151
self.keys.keys().copied().collect()
5252
}
5353

54-
/// Signs an attestation message for the specified validator.
54+
/// Signs a message for the specified validator.
5555
///
5656
/// # Arguments
5757
///
@@ -68,13 +68,13 @@ impl KeyManager {
6868
/// # Example
6969
///
7070
/// ```ignore
71-
/// let signature = key_manager.sign_attestation(
71+
/// let signature = key_manager.sign_message(
7272
/// validator_id,
7373
/// epoch,
7474
/// &message_hash
7575
/// )?;
7676
/// ```
77-
pub fn sign_attestation(
77+
fn sign_message(
7878
&mut self,
7979
validator_id: u64,
8080
epoch: u32,
@@ -96,6 +96,15 @@ impl KeyManager {
9696

9797
Ok(xmss_sig)
9898
}
99+
100+
pub fn sign_attestation(
101+
&mut self,
102+
attestation: &Attestation,
103+
) -> Result<XmssSignature, KeyManagerError> {
104+
let message_hash = attestation.tree_hash_root();
105+
let epoch = attestation.data.slot as u32;
106+
self.sign_message(attestation.validator_id, epoch, &message_hash)
107+
}
99108
}
100109

101110
#[cfg(test)]
@@ -110,12 +119,12 @@ mod tests {
110119
}
111120

112121
#[test]
113-
fn test_sign_attestation_validator_not_found() {
122+
fn test_sign_message_validator_not_found() {
114123
let keys = HashMap::new();
115124
let mut key_manager = KeyManager::new(keys);
116125
let message = H256::default();
117126

118-
let result = key_manager.sign_attestation(123, 0, &message);
127+
let result = key_manager.sign_message(123, 0, &message);
119128
assert!(matches!(
120129
result,
121130
Err(KeyManagerError::ValidatorKeyNotFound(123))

0 commit comments

Comments
 (0)