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

fix(net): set status, forkfilter from chainspec #939

Merged
merged 1 commit into from
Jan 20, 2023

Conversation

Rjected
Copy link
Member

@Rjected Rjected commented Jan 19, 2023

Previously, if unset, the fork_filter for the NetworkConfig would be set using the chain_spec and head fields. The status would be its default value, but the fork_filter being generated from the chainspec. As a result, the fork filter would not match the status. This would lead to unintentional disconnects by us on custom networks.

This removes the status and fork_filter fields from the network config builder, and changes the head field type to BlockHashNumber. If unset, the head hash is set to the genesis hash, and the head number set to zero. The Status and ForkFilter are then set based on this head and existing chainspec.

This adds a test checking that the forkid hash and next are set to the correct values, based on the chainspec.

Sets serde as a default feature for reth-network.

 * previously, if unset, the fork_filter would be set using the
   ChainSpec and head. if the status was set, but the fork_filter was
   not set, the fork filter and generated status's forkid would not
   match. this would lead to unintentional disconnects by us on custom
   networks.
 * remove the status and fork_filter fields from the network config
   builder
 * changes the head field to BlockHashNumber
 * if unset, set the head hash to the ChainSpec genesis, and the head
   number to zero
 * derive the Status and ForkFilter based on the current head and
   ChainSpec
 * add a test checking that the forkid hash and next are set to the
   correct values, based on the chainspec
 * set serde as a default feature for reth-network
@Rjected Rjected requested a review from mattsse as a code owner January 19, 2023 23:15
@Rjected Rjected added A-networking Related to networking in general C-bug An unexpected or incorrect behavior labels Jan 19, 2023
Rjected added a commit that referenced this pull request Jan 20, 2023
 * this change and #939 should fix an issue where the fork filter and
   status were set incorrectly, causing a premature disconnect
Rjected added a commit that referenced this pull request Jan 20, 2023
 * this change and #939 should fix an issue where the fork filter and
   status were set incorrectly, causing a premature disconnect
@Rjected Rjected mentioned this pull request Jan 20, 2023
18 tasks
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

nice catch!

@@ -94,5 +94,6 @@ tempfile = "3.3"
serial_test = "0.10"

[features]
default = ["serde"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is reasonable

@mattsse mattsse merged commit eb11da8 into main Jan 20, 2023
@mattsse mattsse deleted the dan/fix-fork-filter-net-config branch January 20, 2023 09:53
Rjected added a commit that referenced this pull request Jan 20, 2023
 * this change and #939 should fix an issue where the fork filter and
   status were set incorrectly, causing a premature disconnect
Rjected added a commit that referenced this pull request Jan 22, 2023
 * this change and #939 should fix an issue where the fork filter and
   status were set incorrectly, causing a premature disconnect
Rjected added a commit that referenced this pull request Jan 22, 2023
 * this change and #939 should fix an issue where the fork filter and
   status were set incorrectly, causing a premature disconnect
Rjected added a commit that referenced this pull request Jan 22, 2023
 * this change and #939 should fix an issue where the fork filter and
   status were set incorrectly, causing a premature disconnect
Rjected added a commit that referenced this pull request Jan 27, 2023
 * this change and #939 should fix an issue where the fork filter and
   status were set incorrectly, causing a premature disconnect
Rjected added a commit that referenced this pull request Jan 30, 2023
 * this change and #939 should fix an issue where the fork filter and
   status were set incorrectly, causing a premature disconnect
Rjected added a commit that referenced this pull request Jan 30, 2023
 * this change and #939 should fix an issue where the fork filter and
   status were set incorrectly, causing a premature disconnect
Rjected added a commit that referenced this pull request Jan 30, 2023
 * this change and #939 should fix an issue where the fork filter and
   status were set incorrectly, causing a premature disconnect
literallymarvellous pushed a commit to literallymarvellous/reth that referenced this pull request Feb 5, 2023
literallymarvellous pushed a commit to literallymarvellous/reth that referenced this pull request Feb 5, 2023
literallymarvellous pushed a commit to literallymarvellous/reth that referenced this pull request Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-networking Related to networking in general C-bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants