Skip to content

Fix for #7305: Verify blobs and data columns during backfill #7353

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

Open
wants to merge 5 commits into
base: unstable
Choose a base branch
from

Conversation

SunnysidedJ
Copy link

Issue Addressed

#7305: Verify blobs and data columns during backfill

Proposed Changes

Compare signatures (equality check) for blob and data column sidecars
Then, validate KZG commitments as described in the issue.

Additional Info

This will be further compared and leveraged with #7352 as some parts of this issue is also covered as part of the issue it is fixing. So, WIP and will let you know once it is ready under the comments.

@SunnysidedJ
Copy link
Author

Currently under debugging its test case. The test is:

async fn weak_subjectivity_sync_skips_at_genesis() {

However, the test does not run properly when Deneb or Fulu is enabled, e.g. FORK_NAME=deneb cargo test weak_subjectivity_sync --features "fork_from_env".

@jimmygchen jimmygchen added das Data Availability Sampling work-in-progress PR is a work-in-progress labels Apr 30, 2025
@@ -783,23 +783,6 @@ impl<E: EthSpec> AvailableBlock<E> {
} = self;
(block_root, block, blob_data)
}

/// Only used for testing
Copy link
Author

Choose a reason for hiding this comment

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

Removed as it is no longer called in testing (moved to RpcBlock)

// Verify that blobs or data columns signatures match
let sig_timer = metrics::start_timer(&metrics::BACKFILL_SIGNATURE_TOTAL_TIMES);
let setup_timer = metrics::start_timer(&metrics::BACKFILL_SIGNATURE_SETUP_TIMES);
// TODO: this logic is redundant with one from range sync. Do we have a good place to make
Copy link
Author

Choose a reason for hiding this comment

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

QQ

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe move it inside of verify_kzg_for_rpc_blocks?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, forgot to integrate this. Let me do it tomorrow!

impl<T: BeaconChainTypes> BeaconChain<T> {
fn verify_blobs_and_data_columns(
Copy link
Author

Choose a reason for hiding this comment

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

pulled out verification parts as import_historical_block_batch() has become too long

@SunnysidedJ
Copy link
Author

Status: Ready for review.
Tests run:

  1. pre-Deneb: as it is in store_tests.rs
  2. pre-Fulu, post-Deneb: + incorrect signature in blob header + incorrect KZG commitment in blob
  3. post-Fulu: + incorrect signature in data column header + incorrect KZG commitment in data column

@SunnysidedJ
Copy link
Author

Hey @dapplion, I much liked your implementation from #7352, where you've used existing functions I wasn't aware of and also made helper functions that share the same logics between range sync.

I tried to minimize the conflicts I hope this is okay with you. Please let me know for any comments!

There're a few parts that I changed from yours.

  1. I made minimal changes to sync_methods.rs as there are many more changes related to your PR (peer scoring itself).
  2. Didn't take assert_correct_historical_block_chain() because if import_historical_block_batch() bails during block signature verification, the oldest block parent is updated regardless. I think this shouldn't happen (I think you also mentioned about DB stuff in your comment?). However, I left as it is to preserve working code.
  3. Properly added timer metrics

I haven't made any changes to the range sync verification as it wasn't scope of the issue (I would've done it if I was aware of) and thought it would create more conflicts between your PR.

@SunnysidedJ SunnysidedJ marked this pull request as ready for review April 30, 2025 13:19
@SunnysidedJ SunnysidedJ requested a review from jxs as a code owner April 30, 2025 13:19
// Verify that blobs or data columns signatures match
let sig_timer = metrics::start_timer(&metrics::BACKFILL_SIGNATURE_TOTAL_TIMES);
let setup_timer = metrics::start_timer(&metrics::BACKFILL_SIGNATURE_SETUP_TIMES);
// TODO: this logic is redundant with one from range sync. Do we have a good place to make
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe move it inside of verify_kzg_for_rpc_blocks?

drop(verify_timer);
drop(sig_timer);
// Verify signatures in a batch.
self.verify_available_block_signatures(&signed_blocks)?;
Copy link
Collaborator

@dapplion dapplion Apr 30, 2025

Choose a reason for hiding this comment

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

Order of ops should be:

  • verify block signatures
  • match block and sidecar headers
  • verify kzg proofs

To do proper scoring later

| HistoricalBlockError::InvalidDataColumnsSignature(_)
| HistoricalBlockError::Unexpected(_)
| HistoricalBlockError::AvailabilityCheckError(_) => {
warn!(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Only internal errors should be a warn, peers can send invalid objects and users can't do anything about it.

@@ -2279,6 +2279,9 @@ async fn weak_subjectivity_sync_test(slots: Vec<Slot>, checkpoint_slot: Slot) {
let temp1 = tempdir().unwrap();
let full_store = get_store(&temp1);

let is_deneb = full_store.get_chain_spec().deneb_fork_epoch.is_some();
let is_fulu = full_store.get_chain_spec().is_peer_das_scheduled();
Copy link
Collaborator

Choose a reason for hiding this comment

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

ForkName::fulu_enabled()

@@ -2279,6 +2279,9 @@ async fn weak_subjectivity_sync_test(slots: Vec<Slot>, checkpoint_slot: Slot) {
let temp1 = tempdir().unwrap();
let full_store = get_store(&temp1);

let is_deneb = full_store.get_chain_spec().deneb_fork_epoch.is_some();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use ForkName::deneb_enabled()

Copy link
Author

Choose a reason for hiding this comment

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

The way I think I can use is something like fork_name_at_slot::(Slot::new(0)). I can see that it is safer to use ForkName than ChainSpec (that it checks previous forks are enabled), but I'm not sure it is cleaner here, and all others are using this format.

false
}
})
.unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you need to find this position? Just setup the rpc_blocks such that the first block always has data

Copy link
Author

Choose a reason for hiding this comment

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

Then, we might get to test non-first index as well!

@SunnysidedJ
Copy link
Author

Restructured backfill importing such that

  1. it now clearly separates block validation and storing.
  2. it follows PeerDAS scoring order

@SunnysidedJ SunnysidedJ requested a review from dapplion May 8, 2025 11:25
@SunnysidedJ
Copy link
Author

@dapplion could you review the PR?

@dapplion
Copy link
Collaborator

We are focusing on merging #7352 first, will port the remaining diff from here later

@dapplion dapplion mentioned this pull request May 19, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
das Data Availability Sampling work-in-progress PR is a work-in-progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants