Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
57810ee
Download all headers new to old as first step of fullsync
fmoletta Oct 8, 2025
81866ce
fix
fmoletta Oct 9, 2025
c02da60
Some fixes + debug
fmoletta Oct 13, 2025
678d29b
fix
fmoletta Oct 13, 2025
67da9ca
Invalidate child when checking for invalid parent
fmoletta Oct 13, 2025
e2a93d6
Tidy up code
fmoletta Oct 13, 2025
931de19
Avoid writing header batch to DB if we only have 1 header batch to pr…
fmoletta Oct 13, 2025
b5ce864
Add InMemory impl
fmoletta Oct 13, 2025
524055c
Wipe header table after sync is done'
fmoletta Oct 13, 2025
acca858
fix
fmoletta Oct 13, 2025
181bc04
Clippy
fmoletta Oct 14, 2025
26d5066
fix
fmoletta Oct 14, 2025
41475ab
Tidy up code
fmoletta Oct 14, 2025
f8c2936
fix(snap->full) launch full sync cycle instead of relying on BlockSta…
fmoletta Oct 14, 2025
e0845fe
Remove BlockSyncState::Full
fmoletta Oct 14, 2025
116ec2c
Remove BlockSyncState enum
fmoletta Oct 14, 2025
c9be0e6
Doc new methods
fmoletta Oct 14, 2025
dda6c75
Normalize tracing
fmoletta Oct 14, 2025
4f2eb9d
[REVERTME] more agressive logging + unwraps
fmoletta Oct 14, 2025
648970e
Fix
fmoletta Oct 14, 2025
a3cc994
fix
fmoletta Oct 14, 2025
8733ab2
fix
fmoletta Oct 14, 2025
8a70cc5
Revert "[REVERTME] more agressive logging + unwraps"
fmoletta Oct 14, 2025
90ddd87
fix
fmoletta Oct 14, 2025
12d7ba4
upgrade log
fmoletta Oct 14, 2025
1739c43
[REVERTME] debug
fmoletta Oct 15, 2025
24f4f61
Merge branch 'main' of github.com:lambdaclass/ethrex into full-sync-d…
fmoletta Oct 15, 2025
17abf37
[REVERTME] debug
fmoletta Oct 15, 2025
fe998d9
[REVERTME] debug
fmoletta Oct 15, 2025
24d01cb
[DEBUGFIX]: analyse edge case
fmoletta Oct 15, 2025
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
11 changes: 11 additions & 0 deletions crates/blockchain/fork_choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use ethrex_common::{
types::{BlockHash, BlockHeader, BlockNumber},
};
use ethrex_storage::{Store, error::StoreError};
use tracing::info;

use crate::{
error::{self, InvalidForkChoice},
Expand All @@ -24,6 +25,9 @@ pub async fn apply_fork_choice(
safe_hash: H256,
finalized_hash: H256,
) -> Result<BlockHeader, InvalidForkChoice> {
info!(
"Applying fork choice: head: {head_hash}, safe: {safe_hash}, finalized: {finalized_hash}"
);
if head_hash.is_zero() {
return Err(InvalidForkChoice::InvalidHeadHash);
}
Expand All @@ -42,6 +46,13 @@ pub async fn apply_fork_choice(

let head_res = store.get_block_header_by_hash(head_hash)?;

info!(
"Applying fork choice: head: {head_hash}:{:?}, safe: {safe_hash}:{:?}, finalized: {finalized_hash}:{:?}",
head_res.as_ref().map(|h| h.number),
safe_res.as_ref().map(|h| h.number),
finalized_res.as_ref().map(|h| h.number),
);

if !safe_hash.is_zero() {
check_order(&safe_res, &head_res)?;
}
Expand Down
16 changes: 14 additions & 2 deletions crates/blockchain/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ethrex_common::{
use ethrex_storage::Store;
use ethrex_vm::{EvmError, VmDatabase};
use std::{cmp::Ordering, collections::HashMap};
use tracing::instrument;
use tracing::{info, instrument};

#[derive(Clone)]
pub struct StoreVmDatabase {
Expand Down Expand Up @@ -77,7 +77,19 @@ impl VmDatabase for StoreVmDatabase {
}
// If our block is not canonical then we must look for the target in our block's ancestors
} else {
for ancestor_res in self.store.ancestors(self.block_hash) {
let lookup_hash = if self.block_hash_cache.is_empty() {
self.block_hash
} else {
info!(
"[EDGE_CASE]: block hash not in cache but have cache, using oldest block hash for ancestor lookup"
);
self.block_hash_cache
.iter()
.min_by_key(|(n, _)| **n).map(|(_, h)| *h)
.unwrap_or(self.block_hash)
};
// Edge case: we might have some of this block's ancestors cached and some stored, search for furtherst ancestor on the cache befor elooking up stored ancestors
for ancestor_res in self.store.ancestors(lookup_hash) {
let (hash, ancestor) = ancestor_res.map_err(|e| EvmError::DB(e.to_string()))?;
match ancestor.number.cmp(&block_number) {
Ordering::Greater => continue,
Expand Down
4 changes: 2 additions & 2 deletions crates/networking/p2p/peer_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
},
},
snap::encodable_to_proof,
sync::{AccountStorageRoots, BlockSyncState, block_is_stale, update_pivot},
sync::{AccountStorageRoots, SnapBlockSyncState, block_is_stale, update_pivot},
utils::{
AccountsWithStorage, dump_accounts_to_file, dump_storages_to_file,
get_account_state_snapshot_file, get_account_storages_snapshot_file,
Expand Down Expand Up @@ -679,7 +679,7 @@ impl PeerHandler {
limit: H256,
account_state_snapshots_dir: &Path,
pivot_header: &mut BlockHeader,
block_sync_state: &mut BlockSyncState,
block_sync_state: &mut SnapBlockSyncState,
) -> Result<(), PeerHandlerError> {
METRICS
.current_step
Expand Down
Loading
Loading