Skip to content

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

Closed
SunnysidedJ wants to merge 5 commits intosigp:unstablefrom
SunnysidedJ:backfill-verify-blobs-columns
Closed

Fix for #7305: Verify blobs and data columns during backfill#7353
SunnysidedJ wants to merge 5 commits intosigp:unstablefrom
SunnysidedJ:backfill-verify-blobs-columns

Conversation

@SunnysidedJ
Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor 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
(block_root, block, blob_data)
}

/// Only used for testing
Copy link
Copy Markdown
Contributor 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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

QQ

Copy link
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
Contributor 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
Copy Markdown
Contributor 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
Copy Markdown
Contributor 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
Comment thread beacon_node/beacon_chain/src/block_verification_types.rs Outdated
Comment thread beacon_node/beacon_chain/src/data_availability_checker.rs Outdated
Comment thread beacon_node/beacon_chain/src/historical_blocks.rs Outdated
// 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
Copy Markdown
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?

Comment thread beacon_node/beacon_chain/src/historical_blocks.rs Outdated
drop(verify_timer);
drop(sig_timer);
// Verify signatures in a batch.
self.verify_available_block_signatures(&signed_blocks)?;
Copy link
Copy Markdown
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
Copy Markdown
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.

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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ForkName::fulu_enabled()

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
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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
Copy Markdown
Contributor 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!

Comment thread beacon_node/beacon_chain/tests/store_tests.rs Outdated
@SunnysidedJ
Copy link
Copy Markdown
Contributor 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
Copy Markdown
Contributor Author

@dapplion could you review the PR?

@dapplion
Copy link
Copy Markdown
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
@jimmygchen
Copy link
Copy Markdown
Member

This is quite outdated and a lot of the code touched in this PR has changed. Closing this and we'll address this separately.
Thanks for this @SunnysidedJ

@jimmygchen jimmygchen closed this Sep 10, 2025
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