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(core): Do not propagate blocks if subscribed to blocks from incorrect chain #3086

Merged
merged 7 commits into from
Jan 17, 2024

Conversation

renaynay
Copy link
Member

@renaynay renaynay commented Jan 10, 2024

Right now, it is possible for a bridge node that was initialised and started on one chain (e.g. mocha-4) to be stopped and restarted on a different chain (e.g. mainnet) and propagate headers from the old chain (mocha-4) into the different network (mainnet).

This PR fixes this issue by causing the listener to fatal if the listener recognises it is receiving blocks from a different chain to that which it expects.

Error will look like this:

2024-01-10T16:06:22.001+0100	ERROR	core	core/listener.go:175	listener: received block with unexpected chain ID: expected arabica-11, received mocha-4
2024-01-10T16:06:22.001+0100	INFO	core	core/listener.go:177	listener: listening stopped
2024-01-10T16:06:22.001+0100	FATAL	core	core/listener.go:126	listener: invalid subscription

Resolves #3071

@renaynay renaynay added area:core_and_app Relationship with Core node and Celestia-App kind:fix Attached to bug-fixing PRs labels Jan 10, 2024
@renaynay renaynay self-assigned this Jan 10, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jan 10, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (ade25d7) 51.29% compared to head (ad8febe) 51.42%.
Report is 6 commits behind head on main.

Files Patch % Lines
core/listener.go 60.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3086      +/-   ##
==========================================
+ Coverage   51.29%   51.42%   +0.13%     
==========================================
  Files         177      177              
  Lines       11151    11165      +14     
==========================================
+ Hits         5720     5742      +22     
+ Misses       4935     4930       -5     
+ Partials      496      493       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

vgonkivs
vgonkivs previously approved these changes Jan 10, 2024
@vgonkivs
Copy link
Member

vgonkivs commented Jan 10, 2024

Error in swamp test:

2024-01-10T15:12:43.958Z	ERROR	core	core/listener.go:175	listener: received block with unexpected chain ID: expected private, received LM01Di
2024-01-10T15:12:43.958Z	FATAL	core	core/listener.go:126	listener: invalid subscription

distractedm1nd
distractedm1nd previously approved these changes Jan 10, 2024
@renaynay
Copy link
Member Author

Nice example of how i don't check the swamp tests.

@renaynay renaynay enabled auto-merge (squash) January 12, 2024 14:34
@renaynay renaynay merged commit 36205cc into celestiaorg:main Jan 17, 2024
15 of 17 checks passed
renaynay added a commit that referenced this pull request Jan 23, 2024
…rect chain (#3086)

Right now, it is possible for a **bridge** node that was initialised and
started on one chain (e.g. `mocha-4`) to be stopped and restarted on a
different chain (e.g. `mainnet`) and propagate headers from the old
chain (`mocha-4`) into the different network (`mainnet`).

This PR fixes this issue by causing the listener to fatal if the
listener recognises it is receiving blocks from a different chain to
that which it expects.

Error will look like this: 

```
2024-01-10T16:06:22.001+0100	ERROR	core	core/listener.go:175	listener: received block with unexpected chain ID: expected arabica-11, received mocha-4
2024-01-10T16:06:22.001+0100	INFO	core	core/listener.go:177	listener: listening stopped
2024-01-10T16:06:22.001+0100	FATAL	core	core/listener.go:126	listener: invalid subscription
```

Resolves #3071
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core_and_app Relationship with Core node and Celestia-App kind:fix Attached to bug-fixing PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

header/p2p: Mainnet nodes getting mocha-4 headers
6 participants