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

Pre-C Bindings Cleanup #620

Merged

Conversation

TheBlueMatt
Copy link
Collaborator

This is some of the groundwork needed for #618, but which is generally applicable. Most of the cleanups are also slightly cleaner code, so easy to land this before.

@TheBlueMatt TheBlueMatt force-pushed the 2020-05-pre-bindings-cleanups branch 3 times, most recently from cd8520e to 8f23cf4 Compare May 12, 2020 18:48
@codecov
Copy link

codecov bot commented May 12, 2020

Codecov Report

Merging #620 into master will increase coverage by 0.06%.
The diff coverage is 95.83%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #620      +/-   ##
==========================================
+ Coverage   91.29%   91.35%   +0.06%     
==========================================
  Files          35       35              
  Lines       20776    20775       -1     
==========================================
+ Hits        18967    18979      +12     
+ Misses       1809     1796      -13     
Impacted Files Coverage Δ
lightning/src/chain/transaction.rs 100.00% <ø> (ø)
lightning/src/ln/chan_utils.rs 97.18% <ø> (+<0.01%) ⬆️
lightning/src/ln/channelmonitor.rs 95.44% <ø> (-0.08%) ⬇️
lightning/src/util/macro_logger.rs 89.28% <0.00%> (ø)
lightning/src/ln/channelmanager.rs 85.46% <66.66%> (-0.06%) ⬇️
lightning/src/util/test_utils.rs 85.00% <96.49%> (+7.15%) ⬆️
lightning/src/chain/keysinterface.rs 96.96% <100.00%> (ø)
lightning/src/ln/channel.rs 86.62% <100.00%> (ø)
lightning/src/ln/functional_test_utils.rs 94.67% <100.00%> (ø)
lightning/src/ln/functional_tests.rs 97.41% <100.00%> (+0.09%) ⬆️
... and 14 more

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 d4ad57b...ba06507. Read the comment docs.

Comment on lines +762 to +773
/// The concrete type which signs for transactions and provides access to our channel public
/// keys.
type Keys: ChannelKeys;
Copy link
Contributor

Choose a reason for hiding this comment

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

s/which/that

Or how about simply "Keys needed to operate the monitored channels."?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We're slowly moving away from it being keys and more towards it being an interface which signs for things (eg a hardware wallet).

lightning/src/util/test_utils.rs Outdated Show resolved Hide resolved
lightning/src/chain/keysinterface.rs Outdated Show resolved Hide resolved
@TheBlueMatt TheBlueMatt force-pushed the 2020-05-pre-bindings-cleanups branch 2 times, most recently from 5b81cc6 to 1523501 Compare May 16, 2020 21:42
This makes it easier for our automated bindings generator to
function as it tries to automatically create a ::new if the struct
contains only pub elements who's type is convertible.
@jkczyz
Copy link
Contributor

jkczyz commented May 18, 2020

Looks good but needs rebase

@TheBlueMatt TheBlueMatt force-pushed the 2020-05-pre-bindings-cleanups branch from 1523501 to 7411aad Compare May 18, 2020 21:23
fuzz/src/full_stack.rs Outdated Show resolved Hide resolved
@@ -172,41 +174,105 @@ impl events::MessageSendEventsProvider for TestChannelMessageHandler {
}
}

fn get_dummy_channel_announcement(short_chan_id: u64) -> msgs::ChannelAnnouncement {
Copy link

Choose a reason for hiding this comment

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

Test helpers move could have been commented in commit or at least splitted to ease review. That's okay AFAICT, they don't break anything.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just commented it in the commit.

lightning/src/chain/keysinterface.rs Outdated Show resolved Hide resolved
Instead of using a raw generic type, an associted type allows us
to have explicit docs on the type, which is nice. More importantly,
however, our automated bindings generator knows how to read
associated types but not raw generics.

Also, our bindings generator expects things which are referenced to
have already been defined, so we move ManyChannelMonitor below the
ChannelMonitor definition.
We also update to use single idents when referencing the Deref=*
types since the automated code generator is pretty braindead.

This also moves some test utils out of peer_handler.rs and into
util::test_utils to standardize things a little bit, which we need
to concretize the PeerHandler types used in testing.
We never actually fail, so we can just drop the Result type.
 * Return Self instead of the fully-written types for constructors,
 * Place definitions before use (in this case for KeysInterface),
 * Don't import foo::bar::self, but import foo::bar

 + a spelling fix in the KeysInterface docs for get_onion_rand.
Its just a trivial bool and already has docs on it, so seems like
an oversight
@TheBlueMatt TheBlueMatt force-pushed the 2020-05-pre-bindings-cleanups branch from 7411aad to ba06507 Compare May 22, 2020 18:30
@TheBlueMatt
Copy link
Collaborator Author

Gonna take this since we already did the review cycles, but there will be more before bindings land.

@TheBlueMatt TheBlueMatt merged commit 2087032 into lightningdevkit:master May 28, 2020
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.

None yet

3 participants