Skip to content

Conversation

acolytec3
Copy link
Contributor

@acolytec3 acolytec3 commented Oct 18, 2024

This PR partially addresses #3750

  • Adds types for devp2p and common events
  • Rewrites the devp2p eth-simulator test so it's comprehensible
  • Removes the les-simulator tests

Copy link

codecov bot commented Oct 18, 2024

Codecov Report

Attention: Patch coverage is 4.00000% with 24 lines in your changes missing coverage. Please review.

Project coverage is 27.44%. Comparing base (dc154fd) to head (0676785).
Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 67.57% <ø> (ø)
blockchain 83.50% <ø> (ø)
client 0.00% <ø> (ø)
common 89.85% <100.00%> (ø)
devp2p 0.00% <0.00%> (ø)
evm 65.22% <0.00%> (+0.01%) ⬆️
genesis 0.00% <ø> (ø)
mpt 52.09% <ø> (ø)
statemanager 67.41% <ø> (ø)
tx 76.70% <ø> (ø)
util 73.46% <ø> (ø)
vm 58.43% <ø> (+0.11%) ⬆️
wallet 0.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

export interface RLPxEvent {
'peer:added': Peer
'peer:error': { peer: Peer; error: any }
'peer:removed': { peer: Peer; reason: any; disconnectWe: any }
Copy link
Contributor

Choose a reason for hiding this comment

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

What is disconnectWe? Is there a more descriptive name for this field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just saying whether we "disconnected" the connection or the remote peer. I'll add some comments on the types.

it('DPT: new working node', () => {
const dpts = util.initTwoPeerDPTSetup(41622)

dpts[0].events.on('peer:new', async (peer: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's actually great to see these events typed in a more meaningful way 🙂, have struggled with what "peer" type is being returned when using the API before.

"test/**/*.ts",
"examples/**/*.ts",
"scripts/**/*.ts",
"examples/simple.cts",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did these change? Were these examples not being included before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We just forgot to update the extension when we migrated over to ESM for our base dev environment. This is just miscellaneous cleanup.

export interface RLPxEvent {
'peer:added': [peer: Peer]
'peer:error': [peer: Peer, error: any]
'peer:removed': [peer: Peer, reason: any, disconnectWe: any] // disconnectWe indicates whether the disconnection was initiated by us or not
Copy link
Contributor

Choose a reason for hiding this comment

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

I typed the disconnectWe as boolean | null. It was typed as that in rlpx/peer.ts and typecheck passes

@gabrocheleau
Copy link
Contributor

Pushed some minor type improvements and reviewed the code, lgtm!

@acolytec3 acolytec3 merged commit 39409df into master Oct 20, 2024
40 of 41 checks passed
@am1r021 am1r021 deleted the more-event-typing-cleanup branch October 21, 2024 17:19
@jochem-brouwer jochem-brouwer mentioned this pull request Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants