Skip to content

Return eth1_data early post transition #7248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 7, 2025

Conversation

pawanjay176
Copy link
Member

@pawanjay176 pawanjay176 commented Apr 2, 2025

Issue Addressed

N/A

Proposed Changes

Return state.eth1_data() early if we have passed the transition period post electra. Even if we don't return early, the function would still return state.eth1_data() based on the current conditions. However, doing this explicitly here to match the spec. This covers setting the right eth1_data in our block.

The other thing we need to ensure is that the deposits returned by the eth1_chain is empty post transition.

The only way we get non-empty deposits post the transition is if state.eth1_deposit_index in the below code is less than min(deposit_requests_start_index, state.eth1_data().deposit_count).

let deposit_count = if let Some(new_eth1_data) = get_new_eth1_data(state, eth1_data_vote)? {
new_eth1_data.deposit_count
} else {
state.eth1_data().deposit_count
};
// [New in Electra:EIP6110]
let deposit_index_limit =
if let Ok(deposit_requests_start_index) = state.deposit_requests_start_index() {
std::cmp::min(deposit_count, deposit_requests_start_index)
} else {
deposit_count
};
match deposit_index.cmp(&deposit_index_limit) {
Ordering::Greater => Err(Error::DepositIndexTooHigh),
Ordering::Equal => Ok(vec![]),
Ordering::Less => {
let next = deposit_index;
let last = std::cmp::min(deposit_index_limit, next + E::MaxDeposits::to_u64());
self.core
.deposits()
.read()
.cache
.get_deposits(next, last, deposit_count)
.map_err(|e| Error::BackendError(format!("Failed to get deposits: {:?}", e)))
.map(|(_deposit_root, deposits)| deposits)
}
}
}
fn latest_cached_block(&self) -> Option<Eth1Block> {
self.core.latest_cached_block()
}
/// This only writes the eth1_data to a temporary cache so that the service

This can never happen because state.eth1_deposit_index will be equal to state.eth1_data.deposit count and cannot exceed the value.

@michaelsproul @ethDreamer please double check the logic for deposits being empty post transition. Following the logic in the spec makes my head hurt.

@pawanjay176 pawanjay176 requested a review from Copilot April 2, 2025 21:53
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR explicitly returns state.eth1_data() early if state.eth1_deposit_index equals the deposit_requests_start_index, ensuring compliance with the Electra:EIP6110 specification.

  • Updated DummyEth1ChainBackend to include the early return.
  • Added similar logic in CachingEth1Backend to enforce correct behavior post transition.

@pawanjay176 pawanjay176 added ready-for-review The code is ready for review v7.0.0 New release c. Q1 2025 labels Apr 2, 2025
@michaelsproul
Copy link
Member

This looks ok, but I'm not sure if it's comprehensive enough to silence all deposit related warnings post Electra?

Things I've heard users complain about failing:

  • Fetching deposits to build the cache (we shouldn't fetch them at all)
  • Fetching eth1 data (this PR should fix this)
  • Something about the deposit snapshot during finalization

I don't have any more time to look at this week, but will dive back in on Monday

@pawanjay176
Copy link
Member Author

Fetching deposits to build the cache (we shouldn't fetch them at all)

I think this is kinda hard to do. In order to do this, we need to somehow tell the eth1 service to stop fetching logs after the electra_fork_epoch + the transition period in which we fill in all bridge deposits. I think this would be a decent amount of work for writing that code would literally go away the first release after electra so I'm not super keen on that.

Something about the deposit snapshot during finalization

This will be an issue for users who try to do a fresh checkpoint sync from a server that has passed the transition period and isn't able to finalize the snapshot anymore. I think the impact would be not too bad. We saw those issues on holesky because a lot of people were doing fresh syncs, but I didn't see it as much on sepolia. Correct me if i'm wrong here cc @chong-he
A potential improvement here would be to disable serving the deposit_snapshot http endpoint post electra.

I can't think of changes that are simple and high impact in terms of fewer unnessary error logs for users. I feel the best way forward would be to make a release with #7133 around the time when the ELs do their releases to drop pre-merge history post electra.

@chong-he
Copy link
Member

chong-he commented Apr 4, 2025

We saw those issues on holesky because a lot of people were doing fresh syncs, but I didn't see it as much on sepolia. Correct me if i'm wrong here cc @chong-he A potential improvement here would be to disable serving the deposit_snapshot http endpoint post electra.

Yes we don't see the log from Sepolia. They are from Holesky testnet, probably because of fresh checkpoint sync as you mentioned

Copy link
Member

@michaelsproul michaelsproul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'm satisfied that this matches the spec for get_eth1_vote (https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/validator.md#deposits), and that we will return vec![] once all the old-style deposits are processed.

I made a commit on my fork where I renamed some variables to convince myself that we were matching the spec.

@michaelsproul michaelsproul added ready-for-merge This PR is ready to merge. and removed ready-for-review The code is ready for review labels Apr 7, 2025
mergify bot added a commit that referenced this pull request Apr 7, 2025
@mergify mergify bot merged commit 091e292 into sigp:release-v7.0.0 Apr 7, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge This PR is ready to merge. v7.0.0 New release c. Q1 2025
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants