Skip to content

Conversation

varun-doshi
Copy link
Contributor

Fixes #251

Changes:

  • Introduces a blocks_seen: LruCache<(B256, Signature)> in ScrollNetworkManager which is responsible to caching (block_hash, signature) pair
  • Checks for duplicate incoming (block_hash, sig) in 2 places:
    • on_scroll_wire_event
    • handle_eth_wire_block
  • If it is a duplicate block ,it will not process that further.
  • If it not a duplicate block, it will add cache to two places: blocks_seen and per peer cache. Then will continue to process that block
  • Note: currently cache size for block_seen is set to 100 which is same as that of the peer cache(will update this as advised)

To-do:

  • punish peers who send duplicate blocks

@varun-doshi
Copy link
Contributor Author

@jonastheis the PR is ready for review. Will proceed on peer punishment based on your advice

Copy link
Contributor

@jonastheis jonastheis left a comment

Choose a reason for hiding this comment

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

I think we can skip peer penalization for now as it is also not done in reth. We might also keep the same LRU size. We can always adjust later.

Then there's mainly linter errors and merge conflicts to address + some comments

trace!(target: "scroll::network::manager", peer_id = ?peer, block = ?msg.block, "Block import successful - announcing block to network");
let hash = msg.block.hash_slow();
// Update the state of the peer cache i.e. peer has seen this block.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need this here? If we marked the peer already just after we received the block this shouldn't be necessary? @frisitano to confirm

if self.blocks_seen.contains(&(block_hash, signature)) {
return None;
} else {
// Update the state of the peer cache i.e. peer has seen this block.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any risk marking a peer as having seen this block at this stage @frisitano?

Ok(BlockValidation::ValidBlock { new_block: msg }) |
Ok(BlockValidation::ValidHeader { new_block: msg }) => {
Ok(BlockValidation::ValidBlock { new_block: msg })
| Ok(BlockValidation::ValidHeader { new_block: msg }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you'll need to run the linter with rust nightly to accomodate to our linting rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Network] Avoid processing the same (block, signature) tuple multiple times
2 participants