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

XU networks support #827

Merged
merged 15 commits into from
Apr 9, 2019
Merged

XU networks support #827

merged 15 commits into from
Apr 9, 2019

Conversation

moshababo
Copy link
Collaborator

@moshababo moshababo commented Mar 12, 2019

Closes #781.

This required less changes then I expected, since we're not directly communicating with the underlying blockchains clients, but only with the 2nd layer clients. It might require more work on the docker config though (@reliveyy).

  • each node is now associated with a specific XU network
  • mainnet & testnet seed nodes are empty for now
  • added mapping between XU network to LN network config
  • XU network can be selected using n arg (-n=testnet for example). @kilrau let me know if you want me to change that to be used as a boolean signal, e.g. --testnet

BREAKING CHANGE: nodes database table scheme.

@moshababo moshababo requested review from a user and sangaman March 12, 2019 15:42
@kilrau kilrau requested a review from reliveyy March 12, 2019 17:10
@kilrau
Copy link
Contributor

kilrau commented Mar 12, 2019

Great!! Indeed I would say --testnet-style command line args are more common and therefore preferable.

@ghost ghost assigned moshababo Mar 14, 2019
@ghost ghost added the in progress label Mar 14, 2019
# Conflicts:
#	lib/Config.ts
#	test/p2p/sanity.spec.ts
@moshababo
Copy link
Collaborator Author

@kilrau done.

Copy link
Collaborator

@sangaman sangaman left a comment

Choose a reason for hiding this comment

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

Sorry for not reviewing or discussing this change sooner but I finally went through this PR and the associated issue closely. I'll probably need to review again with a fresh set of eyes since this touches a lot of things. A couple of points in addition to the comments below:

  1. I think it may make sense to use separate databases for each network, rather than just differentiating the nodes by network in the nodes table. The reason being that each network is entirely distinct from one another, and data that applies to one network is unrelated to data for another network. As an example, we wouldn't want testnet data contaminating/bloating the mainnet database.

  2. I don't fully understand the need for the lnNetwork in addition to the xu network. Aren't these always going to be the same?

  3. I sort of liked the way the commands arg for network was before with -n, although I get the appeal of being able to write out --testnet and such so I'm ok with leaving it if that's what others prefer. However it differs from the way you'd specify the network in the config file, which is still like network = "simnet" (and where having to write out testnet = true is a little clunkier). A neater solution might be to convert the boolean arguments to a string network argument within the xud bin file before passing it to the xud server code. You can also use yargsbuilt-inconflicts` API so that yargs will throw an error if a user tries to pass in more than one network value rather than having to check for that yourself. It would look like this:

.conflicts('mainnet', ['testnet', 'simnet', 'regtest'])
.conflicts('testnet', ['mainnet', 'simnet', 'regtest'])
// same for last two

@kilrau
Copy link
Contributor

kilrau commented Mar 24, 2019

I think it may make sense to use separate databases for each network
data that applies to one network is unrelated to data for another network. As an example, we wouldn't want testnet data contaminating/bloating the mainnet database.

Agree!

@moshababo
Copy link
Collaborator Author

I think it may make sense to use separate databases for each network, rather than just differentiating the nodes by network in the nodes table. The reason being that each network is entirely distinct from one another, and data that applies to one network is unrelated to data for another network. As an example, we wouldn't want testnet data contaminating/bloating the mainnet database.

Sounds good, will do.

I don't fully understand the need for the lnNetwork in addition to the xu network. Aren't these always going to be the same?

See my comment here.

I sort of liked the way the commands arg for network was before with -n, although I get the appeal of being able to write out --testnet and such so I'm ok with leaving it if that's what others prefer. However it differs from the way you'd specify the network in the config file, which is still like network = "simnet" (and where having to write out testnet = true is a little clunkier). A neater solution might be to convert the boolean arguments to a string network argument within the xudbin file before passing it to the xud server code. You can also use yargsbuilt-inconflicts` API so that yargs will throw an error if a user tries to pass in more than one network value rather than having to check for that yourself. It would look like this:

Thanks, i’ll check it out.

@ghost
Copy link

ghost commented Mar 26, 2019

I think it may make sense to use separate databases for each network

You could also consider using a separate schema per network if having separate DBs is too much work.

@moshababo moshababo requested a review from sangaman March 30, 2019 19:15
Copy link
Collaborator

@sangaman sangaman left a comment

Choose a reason for hiding this comment

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

Looks great, I'd like to test this manually a bit before merging since it's a big PR but the code looks good. Thanks for making those changes.

break;
}
}
}

private getDefaultDbPath = () => {
return path.join(this.xudir, 'xud.db');
return path.join(this.xudir, `xud-${this.network}.db`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a thought but we can keep the xud.db filename for mainnet and only specify a network if it's not mainnet, so this would be something like:

this.network === XuNetwork.MainNet ? 'xud.db' : `xud-${this.network}.db`

Copy link

Choose a reason for hiding this comment

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

I wouldn't mind it being more explicit for each network.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, i'd rather have it be more explicit.

@sangaman sangaman added the breaking A breaking or non-backwards compatible change label Apr 3, 2019
break;
}
}
}

private getDefaultDbPath = () => {
return path.join(this.xudir, 'xud.db');
return path.join(this.xudir, `xud-${this.network}.db`);
Copy link

Choose a reason for hiding this comment

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

I wouldn't mind it being more explicit for each network.

@@ -0,0 +1,16 @@
import * as db from '../../db/types';

export default [
Copy link

Choose a reason for hiding this comment

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

Really nice to have these seeds on a network level :).

@ghost
Copy link

ghost commented Apr 6, 2019

Also, needs a rebase.

# Conflicts:
#	lib/db/DB.ts
#	lib/p2p/Peer.ts
#	lib/p2p/Pool.ts
#	test/unit/DB.spec.ts
@moshababo
Copy link
Collaborator Author

@sangaman I wasn't sure if you still want to manually test this, so i'll leave it open for you to merge.

@sangaman
Copy link
Collaborator

sangaman commented Apr 9, 2019

Thanks. I'm merging this now and will do #869 shortly after since they both involve breaking db changes.

@sangaman sangaman merged commit a5a06e1 into master Apr 9, 2019
@sangaman sangaman deleted the xunetworks branch April 9, 2019 15:49
@ghost ghost removed the in progress label Apr 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking A breaking or non-backwards compatible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants