Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

wire_refactor#187

Merged
bmancini55 merged 10 commits intonode-lightning:mainfrom
Vib-UX:wire_refactor
Aug 16, 2021
Merged

wire_refactor#187
bmancini55 merged 10 commits intonode-lightning:mainfrom
Vib-UX:wire_refactor

Conversation

@Vib-UX
Copy link
Contributor

@Vib-UX Vib-UX commented Aug 5, 2021

fixes #183 wire: refactor message types to use @node-lightning/bitcoin types

@codecov-commenter
Copy link

codecov-commenter commented Aug 5, 2021

Codecov Report

Merging #187 (314fb00) into main (de8afec) will decrease coverage by 0.03%.
The diff coverage is 86.95%.

❗ Current head 314fb00 differs from pull request most recent head d792690. Consider uploading reports for the commit d792690 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #187      +/-   ##
==========================================
- Coverage   93.71%   93.67%   -0.04%     
==========================================
  Files         179      179              
  Lines        4693     4696       +3     
  Branches      547      547              
==========================================
+ Hits         4398     4399       +1     
- Misses        163      165       +2     
  Partials      132      132              
Impacted Files Coverage Δ
packages/bitcoin/lib/Value.ts 85.71% <0.00%> (-14.29%) ⬇️
packages/wire/lib/messages/ChannelUpdateMessage.ts 72.60% <69.23%> (ø)
...h/lib/deserialize/channel-settings-from-message.ts 100.00% <100.00%> (ø)
packages/wire/lib/messages/AcceptChannelMessage.ts 96.15% <100.00%> (+0.07%) ⬆️
packages/wire/lib/messages/ClosingSignedMessage.ts 100.00% <100.00%> (ø)
packages/wire/lib/messages/OpenChannelMessage.ts 96.96% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de8afec...d792690. Read the comment docs.

@Vib-UX
Copy link
Contributor Author

Vib-UX commented Aug 5, 2021

Not sure why the build error? 🤔

Copy link
Member

@bmancini55 bmancini55 left a comment

Choose a reason for hiding this comment

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

First pass is looking good. Couple minors and wanted your thoughts on a few properties in channel_update

@Vib-UX Vib-UX requested a review from bmancini55 August 10, 2021 05:33
Copy link
Member

@bmancini55 bmancini55 left a comment

Choose a reason for hiding this comment

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

Apologies for the review delay. Just a minor change to naming, otherwise looks good!

@bmancini55
Copy link
Member

Not sure why the build error? thinking

Check to make sure npm run build works in the wire project. Sometimes interdependencies can be tricky as well, the error is happening inside gossip-rocksdb project.

From the project root you can run npm run bootstrap and it should reproduce the error locally.

@Vib-UX
Copy link
Contributor Author

Vib-UX commented Aug 11, 2021

Not sure why the build error? thinking

Check to make sure npm run build works in the wire project. Sometimes interdependencies can be tricky as well, the error is happening inside gossip-rocksdb project.

From the project root you can run npm run bootstrap and it should reproduce the error locally.

Locally its showing success.


image

image

@Vib-UX Vib-UX requested a review from bmancini55 August 11, 2021 23:55
@bmancini55
Copy link
Member

Whew, ok, that took a bit to unpack what is going on.

The short answer is that by adding types from the bitcoin project to output from the wire project, the TypeScript build output no longer has a shared root path. Previously all types were part of /wire/lib which is not included in the dist path. The package.json's main path of /wire/dist/index.js worked. Now because of the bitcoin types, the main entry for the package.json must be set to /wire/dist/wire/lib/index.js. This is observerable if you

  1. navigate to the wire project folder, cd packages/wire
  2. remove the dist folder, rm -rf dist
  3. rebuild the project, npm run build
  4. view the contents of the dist, ls dist

You'll see that it now contains two directories, bitcoin and wire. And wire/lib/index.js is the entry point for the library.

So... to repro the build error:

  1. from the root of the node-lightning project
  2. delete all build data (I'm going to make a new issue to ensure this happens prior to builds)
find ./packages -name "dist" -exec rm -rf {} \;
find ./packages -name "node_modules" -exec rm -rf {};
  1. Rerun bootstrap, npm run bootstrap
  2. It will fail with the same error in the build.

You can now fix the wire project by changing package.json so that main points to dist/wire/lib/index.js.

Rerunning npm run bootstrap at the project root will reveal the actual build errors that still exist inside the graph project!

@bmancini55
Copy link
Member

Ah.. it's much simpler than that. Should have done a more thorough code review first!

In a number of files you import Value via the path ../../../bitcoin/lib/Value (sometimes VS Code imports via relative paths instead of the projects). This path needs to be changed to @node-lightning/core and you'll be able to reproduce the build errors.

@Vib-UX
Copy link
Contributor Author

Vib-UX commented Aug 12, 2021

Ah.. it's much simpler than that. Should have done a more thorough code review first!

In a number of files you import Value via the path ../../../bitcoin/lib/Value (sometimes VS Code imports via relative paths instead of the projects). This path needs to be changed to @node-lightning/core and you'll be able to reproduce the build errors.

Ooh, 😮 didn't think that would be the case. 👍

Copy link
Member

@bmancini55 bmancini55 left a comment

Choose a reason for hiding this comment

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

Need to make sure the tests for GraphMaanger are still valid. You'll either need to modify the helper to generate the Value types in the spec file or modify channelSettingsFromMessage to null check and return 0 if it's null.

instance.htlcMaximumMsat = msg.htlcMaximumMsat;
instance.feeBaseMsat = msg.feeBaseMsat;
instance.feeProportionalMillionths = msg.feeProportionalMillionths;
instance.htlcMinimumMsat = msg.htlcMinimumMsat.msats;
Copy link
Member

Choose a reason for hiding this comment

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

Even though this shouldn't be null, let's perform a null check on these properties. This will allow the test for GraphManager to succeed.

Copy link
Contributor Author

@Vib-UX Vib-UX Aug 13, 2021

Choose a reason for hiding this comment

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

null check 👍


gossipEmitter.emit("message", createMsg());
gossipEmitter.emit("message", createUpdateMsg(0));
// gossipEmitter.emit("message", createUpdateMsg(0));
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be commented out. Need to either to null check inside channelSettingsFromMessage or fix the helper createUpdateMsg to generate an update message with instantiated Value types.

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 was getting bit trickier to handle so temporarily commented it out, it was showing TypeError: Cannot read property msats of undefined when working with createUpdateMsg.

Sure will try to work around it.

Copy link
Member

Choose a reason for hiding this comment

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

Yep, that's a null ref exception. It's cause by crateUpdateMsg not populating all of the message properties https://github.com/Vib-UX/node-lightning/blob/fe82b0731df63180d43b00e64ee4db43aec2692f/packages/graph/__tests__/graph-manager.spec.ts#L102.


gossipEmitter.emit("message", createMsg());
gossipEmitter.emit("message", createUpdateMsg(1));
// gossipEmitter.emit("message", createUpdateMsg(0));
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.

Copy link
Member

@bmancini55 bmancini55 left a comment

Choose a reason for hiding this comment

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

Looks awesome! Great work!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wire: refactor message types to use @node-lightning/bitcoin types

3 participants