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
894 changes: 750 additions & 144 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 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 = "73bedc26ed961b110df7ac2e234dc11361a4bf25" }

# SSZ deps
# TODO: roll up our own implementation
Expand All @@ -65,3 +65,5 @@ tree_hash_derive = "0.9.1"
# Build-time version info
vergen = { version = "9", features = ["build", "rustc"] }
vergen-git2 = "9"

rand = "0.9"
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ lint: ## 🔍 Run clippy on all workspace crates
cargo clippy --workspace --all-targets -- -D warnings

test: ## 🧪 Run all tests, then forkchoice tests with skip-signature-verification
cargo test --workspace
# Tests need to be run on release to avoid stack overflows during signature verification/aggregation
cargo test --workspace --release
cargo test -p ethlambda-blockchain --features skip-signature-verification --test forkchoice_spectests

GIT_COMMIT=$(shell git rev-parse HEAD)
Expand All @@ -19,7 +20,7 @@ docker-build: ## 🐳 Build the Docker image
--build-arg GIT_BRANCH=$(GIT_BRANCH) \
-t ghcr.io/lambdaclass/ethlambda:local .

LEAN_SPEC_COMMIT_HASH:=fbbacbea4545be870e25e3c00a90fc69e019c5bb
LEAN_SPEC_COMMIT_HASH:=c187aab89e0ecc6ce9c1fd9304fd708312ea7106

leanSpec:
git clone https://github.com/leanEthereum/leanSpec.git --single-branch
Expand Down
2 changes: 1 addition & 1 deletion crates/blockchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ skip-signature-verification = []
ethlambda-storage.workspace = true
ethlambda-state-transition.workspace = true
ethlambda-fork-choice.workspace = true
ethlambda-crypto.workspace = true
ethlambda-types.workspace = true

spawned-concurrency.workspace = true
Expand All @@ -34,7 +35,6 @@ serde = { workspace = true }
serde_json = { workspace = true }
hex = { workspace = true }
datatest-stable = "0.3.3"
leansig.workspace = true
tree_hash = "0.12.0"
ethereum_ssz = "0.10.0"
ethereum_ssz_derive = "0.10.0"
Expand Down
27 changes: 20 additions & 7 deletions crates/blockchain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use store::Store;
use tokio::sync::mpsc;
use tracing::{error, info, warn};

use crate::store::StoreError;

pub mod key_manager;
pub mod metrics;
pub mod store;
Expand Down Expand Up @@ -102,7 +104,7 @@ impl BlockChainServer {
// At interval 0, check if we will propose (but don't build the block yet).
// Tick forkchoice first to accept attestations, then build the block
// using the freshly-accepted attestations.
let proposer_validator_id = (interval == 0)
let proposer_validator_id = (interval == 0 && slot > 0)
.then(|| self.get_our_proposer(slot))
.flatten();

Expand Down Expand Up @@ -237,7 +239,10 @@ impl BlockChainServer {
};

// Process the block locally before publishing
self.on_block(signed_block.clone());
if let Err(err) = self.process_block(signed_block.clone()) {
error!(%slot, %validator_id, %err, "Failed to process built block");
return;
};

// Publish to gossip network
let Ok(()) = self
Expand All @@ -251,16 +256,24 @@ impl BlockChainServer {
info!(%slot, %validator_id, "Published block");
}

fn on_block(&mut self, signed_block: SignedBlockWithAttestation) {
fn process_block(
&mut self,
signed_block: SignedBlockWithAttestation,
) -> Result<(), StoreError> {
let slot = signed_block.message.block.slot;
if let Err(err) = self.store.on_block(signed_block) {
warn!(%slot, %err, "Failed to process block");
return;
}
self.store.on_block(signed_block)?;
metrics::update_head_slot(slot);
metrics::update_latest_justified_slot(self.store.latest_justified().slot);
metrics::update_latest_finalized_slot(self.store.latest_finalized().slot);
metrics::update_validators_count(self.store.head_state().validators.len() as u64);
Ok(())
}

fn on_block(&mut self, signed_block: SignedBlockWithAttestation) {
let slot = signed_block.message.block.slot;
if let Err(err) = self.process_block(signed_block) {
warn!(%slot, %err, "Failed to process block");
}
}

fn on_gossip_attestation(&mut self, attestation: SignedAttestation) {
Expand Down
Loading