Skip to content
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

Increase network limits #2796

Merged
merged 9 commits into from Nov 16, 2021
Merged

Conversation

pawanjay176
Copy link
Member

Issue Addressed

Addresses spec PR ethereum/consensus-specs#2686

Proposed Changes

Increase the max rpc and gossip sizes to 10Mb from 1Mb. Refactor some ssz bound checking code and add tests for rejecting rpc blocks > MAX_RPC_SIZE.

@pawanjay176 pawanjay176 added kintsugi 🍵 work-in-progress PR is a work-in-progress labels Nov 9, 2021
@pawanjay176 pawanjay176 added ready-for-review The code is ready for review and removed work-in-progress PR is a work-in-progress labels Nov 10, 2021
// length of List * size_of(uint8)
+ (T::max_extra_data_bytes() * <u8 as Encode>::ssz_fixed_len())
// length of List * offset size * max size of transaction
+ (T::max_transactions_per_payload() *ssz::BYTES_PER_LENGTH_OFFSET * T::max_bytes_per_transaction())
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure this is correct.
Perhaps:

(T::max_transactions_per_payload() * (ssz::BYTES_PER_LENGTH_OFFSET + T::max_bytes_per_transaction()))

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry had already fixed this up in b16ca82 but forgot to push the changes.

// Fixed part
Self::empty().as_ssz_bytes().len()
// length of List * size_of(uint8)
+ (T::max_extra_data_bytes() * <u8 as Encode>::ssz_fixed_len())
Copy link
Member

Choose a reason for hiding this comment

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

What is this calculating?
The comment says length of list * size_of(uint8).

It seems the units we are calculating here are bytes. So the multiplication should go like, elements_in_list (dimensionless) * size_in_bytes_of_elements (bytes/element).

The size of a u8 is always going to be 8, so I think its fine to use that constant.

So, for the dimensions to work, the left side has to be dimensionless. max_extra_data_bytes() seems like it is giving a result in bytes already? If that's the case multiplying by 8 will give size in bits right?

Copy link
Member Author

Choose a reason for hiding this comment

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

<u8 as Encode>::ssz_fixed_len() gives the size in bytes = 1. So we are doing T::max_extra_data_bytes() * 1 here.
I thought it'd be consistent to not use constants in the calculation here in case we get another variable length value to calculate here later on.

Sorry the comments were bad here. Cleared it up a bit in 7d3aad2 . Let me know if it's okay :)

@pawanjay176
Copy link
Member Author

The test_blocks_by_range_chunked_rpc test is modified to reject merge payloads > MAX_RPC_SIZE and timeout.
test_blocks_by_root_chunked_rpc still checks the proper closing of the substream at the end of all messages.

Perhaps it would be better to extract the bigger merge payload into a separate test?

@pawanjay176 pawanjay176 force-pushed the network-limits branch 2 times, most recently from c0ead84 to 2a1e383 Compare November 15, 2021 15:56
@AgeManning
Copy link
Member

Tests seem to be failing

@pawanjay176
Copy link
Member Author

Fixed!

@AgeManning AgeManning merged commit 8d9a67a into sigp:kintsugi Nov 16, 2021
paulhauner pushed a commit that referenced this pull request Nov 28, 2021
Fix max packet sizes

Fix max_payload_size function

Add merge block test

Fix max size calculation; fix up test

Clear comments

Add a payload_size_function

Use safe arith for payload calculation

Return an error if block too big in block production

Separate test to check if block is over limit
paulhauner pushed a commit that referenced this pull request Nov 28, 2021
Fix max packet sizes

Fix max_payload_size function

Add merge block test

Fix max size calculation; fix up test

Clear comments

Add a payload_size_function

Use safe arith for payload calculation

Return an error if block too big in block production

Separate test to check if block is over limit
@paulhauner paulhauner mentioned this pull request Nov 28, 2021
paulhauner pushed a commit that referenced this pull request Dec 2, 2021
Fix max packet sizes

Fix max_payload_size function

Add merge block test

Fix max size calculation; fix up test

Clear comments

Add a payload_size_function

Use safe arith for payload calculation

Return an error if block too big in block production

Separate test to check if block is over limit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kintsugi 🍵 ready-for-review The code is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants