Skip to content

Clarify network limits #7175

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 9, 2025

Conversation

pawanjay176
Copy link
Member

@pawanjay176 pawanjay176 commented Mar 20, 2025

Issue Addressed

Resolves #6811

Proposed Changes

Rename GOSSIP_MAX_SIZE to MAX_PAYLOAD_SIZE and remove MAX_CHUNK_SIZE in accordance with the spec.

The spec also "clarifies" the message size limits at different levels. The rpc limits are equivalent to what we had before imo.
The gossip limits have additional checks.

I have gotten rid of the is_bellatrix_enabled checks that used a lower limit (1mb) pre-merge. Since all networks we run start from the merge, I don't think this will break any setups.

@pawanjay176 pawanjay176 requested a review from jxs as a code owner March 20, 2025 02:16
@pawanjay176 pawanjay176 added the ready-for-review The code is ready for review label Mar 20, 2025
Comment on lines +736 to +737
//1MB
1024 * 1024,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why max it at 1MB? Doesn't this void the 10MB limit for mainnet?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@jxs jxs left a comment

Choose a reason for hiding this comment

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

Hi, Pawan, overall looks good! Left two comments

Comment on lines 719 to 721
fn max_compressed_len_snappy(n: usize) -> usize {
32 + n + (n / 6)
}
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't we add guard rails here to not overflow?
I.e.

Suggested change
fn max_compressed_len_snappy(n: usize) -> usize {
32 + n + (n / 6)
}
fn max_compressed_len_snappy(n: usize) -> Option<usize> {
32_usize.checked_add(n)?.checked_add(n/6)
}

and then unwrap_or_() or expect with a message when using it

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah sorry was being lazy. Made it safe arithematic and added a test to make sure default values don't overflow

pub fn max_message_size(&self) -> usize {
std::cmp::max(
// 1024 to account for framing + encoding overhead
Self::max_compressed_len_snappy(self.max_payload_size as usize) + 1024,
Copy link
Member

Choose a reason for hiding this comment

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

same as above regarding guard rails

@pawanjay176 pawanjay176 added the v7.0.0-beta.clean Clean release post Holesky rescue label Mar 28, 2025
@pawanjay176
Copy link
Member Author

@michaelsproul marking this as v7.0.0 as I think we should have this before the mainnet release

@pawanjay176 pawanjay176 added v7.0.0 New release c. Q1 2025 and removed v7.0.0-beta.clean Clean release post Holesky rescue labels Apr 3, 2025
Copy link
Member

@AgeManning AgeManning left a comment

Choose a reason for hiding this comment

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

Looks like a lot of renaming, had a single comment. Otherwise lgtm

/// https://github.com/google/snappy/blob/32ded457c0b1fe78ceb8397632c416568d6714a0/snappy.cc#L218C1-L218C47
/// https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md#max_compressed_len
fn max_compressed_len_snappy(n: usize) -> Option<usize> {
32_usize.checked_add(n)?.checked_add(n / 6)
Copy link
Member

Choose a reason for hiding this comment

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

Rather than panic'ing (we have expects following this), why not just return usize::MAX if it were to overflow?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think silently failing returning a higher max value might not be safe here and could potentially lead to consensus issues.
I have added a test at the end of this file to check that there are no panics based on default mainnet values.

@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 9, 2025
mergify bot added a commit that referenced this pull request Apr 9, 2025
michaelsproul added a commit that referenced this pull request Apr 9, 2025
Squashed commit of the following:

commit bd3afbd
Author: Pawan Dhananjay <pawandhananjay@gmail.com>
Date:   Fri Mar 21 17:05:21 2025 -0700

    Make arithematic safe

commit d6f26e9
Author: Pawan Dhananjay <pawandhananjay@gmail.com>
Date:   Wed Mar 19 15:55:40 2025 -0700

    Update max length conditions

commit e3b8168
Author: Pawan Dhananjay <pawandhananjay@gmail.com>
Date:   Fri Feb 21 18:39:10 2025 -0800

    Rename max_gossip_size and remove max_chunk_size
@michaelsproul michaelsproul mentioned this pull request Apr 9, 2025
@mergify mergify bot merged commit 076f3f0 into sigp:release-v7.0.0 Apr 9, 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.

5 participants