Skip to content

Remove genesis block hash from public API #2025

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

Merged

Conversation

TheBlueMatt
Copy link
Collaborator

@TheBlueMatt TheBlueMatt commented Feb 9, 2023

Forcing users to pass a genesis block hash has ended up being
error-prone largely due to byte-swapping questions for bindings
users. Further, our API is currently inconsistent - in
ChannelManager we take a Bitcoin::Network but in NetworkGraph
we take the genesis block hash.

Luckily NetworkGraph is the only remaining place where we require
users pass the genesis block hash, so swapping it for a Network
is a simple change.

Based on #1980

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

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

CI is unhappy with benchmarking ChannelMananger.

Relatedly, I wonder if BestBlock::from_genesis should really be called BestBlock::from_network?

@TheBlueMatt
Copy link
Collaborator Author

Rebased and renamed from_genesis.

@TheBlueMatt TheBlueMatt force-pushed the 2023-02-no-pub-genesis-hashes branch from 462d899 to d42b9b8 Compare February 15, 2023 06:21
@codecov-commenter
Copy link

codecov-commenter commented Feb 15, 2023

Codecov Report

Base: 87.34% // Head: 87.22% // Decreases project coverage by -0.12% ⚠️

Coverage data is based on head (d42b9b8) compared to base (96c8507).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head d42b9b8 differs from pull request most recent head d7c818a. Consider uploading reports for the commit d7c818a to get more accurate results

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2025      +/-   ##
==========================================
- Coverage   87.34%   87.22%   -0.12%     
==========================================
  Files         101      100       -1     
  Lines       44296    44093     -203     
  Branches    44296    44093     -203     
==========================================
- Hits        38691    38461     -230     
- Misses       5605     5632      +27     
Impacted Files Coverage Δ
lightning/src/ln/channelmanager.rs 85.84% <ø> (-0.65%) ⬇️
lightning-background-processor/src/lib.rs 81.67% <100.00%> (ø)
lightning-rapid-gossip-sync/src/lib.rs 80.00% <100.00%> (+1.73%) ⬆️
lightning-rapid-gossip-sync/src/processing.rs 92.46% <100.00%> (-0.68%) ⬇️
lightning/src/chain/channelmonitor.rs 89.52% <100.00%> (-0.07%) ⬇️
lightning/src/chain/mod.rs 84.21% <100.00%> (ø)
lightning/src/ln/channel.rs 83.63% <100.00%> (-0.37%) ⬇️
lightning/src/ln/functional_test_utils.rs 88.70% <100.00%> (+0.26%) ⬆️
lightning/src/ln/functional_tests.rs 97.20% <100.00%> (-0.10%) ⬇️
lightning/src/ln/outbound_payment.rs 80.20% <100.00%> (+0.24%) ⬆️
... and 37 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

tnull
tnull previously approved these changes Feb 15, 2023
Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

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

LGTM after rebase

@TheBlueMatt
Copy link
Collaborator Author

Rebased.

@tnull
Copy link
Contributor

tnull commented Feb 23, 2023

Seems the rebase broke CI.

Forcing users to pass a genesis block hash has ended up being
error-prone largely due to byte-swapping questions for bindings
users. Further, our API is currently inconsistent - in
`ChannelManager` we take a `Bitcoin::Network` but in `NetworkGraph`
we take the genesis block hash.

Luckily `NetworkGraph` is the only remaining place where we require
users pass the genesis block hash, so swapping it for a `Network`
is a simple change.
@TheBlueMatt
Copy link
Collaborator Author

Oops, sorry about that, amended:

$ git diff-tree -U1 c1f47380d d7c818a3a
diff --git a/lightning-rapid-gossip-sync/src/processing.rs b/lightning-rapid-gossip-sync/src/processing.rs
index 2ee3dcbaa..4b6de04c6 100644
--- a/lightning-rapid-gossip-sync/src/processing.rs
+++ b/lightning-rapid-gossip-sync/src/processing.rs
@@ -554,5 +554,4 @@ mod tests {
 	fn full_update_succeeds_at_the_beginning_of_the_unix_era() {
-		let block_hash = genesis_block(Network::Bitcoin).block_hash();
 		let logger = TestLogger::new();
-		let network_graph = NetworkGraph::new(block_hash, &logger);
+		let network_graph = NetworkGraph::new(Network::Bitcoin, &logger);
 
@@ -570,3 +569,2 @@ mod tests {
 		// this is the timestamp encoded in the binary data of valid_input below
-		let block_hash = genesis_block(Network::Bitcoin).block_hash();
 		let logger = TestLogger::new();
@@ -577,3 +575,3 @@ mod tests {
 		{
-			let network_graph = NetworkGraph::new(block_hash, &logger);
+			let network_graph = NetworkGraph::new(Network::Bitcoin, &logger);
 			assert_eq!(network_graph.read_only().channels().len(), 0);
@@ -587,3 +585,3 @@ mod tests {
 		{
-			let network_graph = NetworkGraph::new(block_hash, &logger);
+			let network_graph = NetworkGraph::new(Network::Bitcoin, &logger);
 			assert_eq!(network_graph.read_only().channels().len(), 0);

@TheBlueMatt TheBlueMatt merged commit 16b3c72 into lightningdevkit:main Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants