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

Initial config spec #93

Merged
merged 13 commits into from
Apr 23, 2019
Merged

Initial config spec #93

merged 13 commits into from
Apr 23, 2019

Conversation

mvid
Copy link
Contributor

@mvid mvid commented Mar 29, 2019

Created to address #63

@mvid mvid requested a review from bigs March 29, 2019 23:25
@ghost ghost assigned mvid Mar 29, 2019
@ghost ghost added the in progress label Mar 29, 2019
specs/CONFIG.md Outdated
* Array[Maddr String]
* `[]`
* `DHT`
* `Enabled`
Copy link
Collaborator

@vyzo vyzo Mar 30, 2019

Choose a reason for hiding this comment

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

I would rather call this Server and Client instead of ClientMode and Enabled. ClientMode also enabls the dht.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Unless there is an implication that we need to set both Enabled and ClientMode to get the dht client behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At least in the Go implementation, the don't seem to depend on each other. Preferably it would be one value that would be chosen from an Enum, though, unless it is possible to have both enabled at the same time?

{
"ListenAddr": "/unix/tmp/p2pd.sock",
"Quiet": false,
"ID": "",
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should probably be missing altogether instead of being empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In terms of real JSON, that is true. But for this "default config" example, do you think we should strike empty labels?

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe rather than having this be a "default" example have it be a "complete" example with all of the fields filled in. as a developer, i find those a lot more helpful, because it lets me know what options are possible at a glance! obv the schema does this, but i think that's useful. we could include the "default" config below it, with empty options elided as suggested.

"ID": "",
"Bootstrap": {
"Enabled": false,
"Peers": []
Copy link
Collaborator

Choose a reason for hiding this comment

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

semantically this looks odd when enabled (the empty Peers list).

Copy link
Collaborator

Choose a reason for hiding this comment

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

It should probably be elided.

@mvid
Copy link
Contributor Author

mvid commented Mar 30, 2019

@jacobheun @vasco-santos @vyzo @bigs + anyone I missed

Any thoughts on how this config should be maintained, and if it should be generated? I was thinking of generating the conf as a protobuf message, since that could be shared between language implementations.

@vyzo
Copy link
Collaborator

vyzo commented Mar 31, 2019

Why not just json? We don't gain anything by using protobuf.

@bigs
Copy link
Contributor

bigs commented Mar 31, 2019 via email

@vyzo
Copy link
Collaborator

vyzo commented Mar 31, 2019

json already does that.

@mvid
Copy link
Contributor Author

mvid commented Mar 31, 2019

JSON doesn't generate the structs we will use to hold the config in Go. There are some third party libs we could use to generate Go structs from JSON, but at that point why would we not use proto like we do everywhere else? If we don't want to generate, then anytime the JSON spec changes, we will also need to change all of the individual language implementations for daemons too.

If we don't care about that, then I will get started on implementation that accepts standard JSON and marshals it into a Go defined struct. I thought I the discussion was worth having.

@vyzo
Copy link
Collaborator

vyzo commented Apr 1, 2019

I don't understand this. We will have to write the structs by hand anyway or write the protobuf for it.
I am very much against using protobuf for configuration -- configuration should always be textual.

@jacobheun
Copy link
Contributor

I agree that we should just use json. Having textual configuration makes it a lot easier for users to be able to view/edit/create configurations with a simple editor. Needing to leverage a generator or processor would feel irritating to me as a user trying to set up a new daemon, or to even just view the config for a running daemon.

@vasco-santos
Copy link
Member

+1 on JSON config here

@bigs
Copy link
Contributor

bigs commented Apr 1, 2019

totally down, but to be clear the idea was to use protobuf’s JSON serializer/deserializer. just use protobuf as source of truth for the structs. i agree it’s a bit overkill.

@raulk
Copy link
Member

raulk commented Apr 3, 2019

What I’m understanding is that we wanted to use protobuf to define an interoperable schema. I think defining a schema is a great idea. How about we write a JSON Schema file for that, and make it part of the specs?

@bigs
Copy link
Contributor

bigs commented Apr 3, 2019

@raulk perfect!

specs/CONFIG.md Outdated
* List of bootstrap peers; defaults to the IPFS DHT peers
* Array[Maddr String]
* `[]`
* `DHT`
Copy link
Member

Choose a reason for hiding this comment

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

As discussed earlier, we should be able to have more control on the DHT configuration.

For example, we have the interop tests for the DHT content fetching blocked by not being able to add custom validators or selectors. Moreover, I think we should be able to add other options to the DHT, such as the random walk config libp2p/js-libp2p-kad-dht/src/index.js#L39-L42 and the constants libp2p/js-libp2p-kad-dhtmaster/src/constants.js#L32-L39. The constants being configurable is a topic that was already discussed a few times in the context of experiments with the testbed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds good, but it also sounds like it's out of scope of this particular ticket. This config should be for the daemon as it currently stands. Any feature additions to the deamon will also need to include appropriate config edits

Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps it should be its own sub object. its absence represents it being disabled. even if it only has one or two options to start. thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

All right, that sounds correct for me! Just mentioned to not fall out of the radar!

It is also important to consider that as we are creating the config now, I think we should at least prepare the dht options to get the remaining configs. Otherwise, if we will expect a string for now, we will create a breaking change afterward.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I edited the DHT property to be an object, and added a field Mode that is an enum of "client", "full" and empty string. It defaults to empty string. It should be easier to add extra fields now.

@vyzo
Copy link
Collaborator

vyzo commented Apr 13, 2019

Can you rebase? There are two new options for the pprof handler. Not sure how well this will play with the generic (cross-daemon) nature of the config, as this is a pretty go-specific thing.

@mvid
Copy link
Contributor Author

mvid commented Apr 16, 2019

@vyzo rebased and included those new options

@mvid mvid requested review from vasco-santos and vyzo and removed request for vasco-santos April 16, 2019 18:38
Copy link
Contributor

@bigs bigs left a comment

Choose a reason for hiding this comment

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

will give a more thorough review in the am but this is looking very good

specs/CONFIG.md Outdated
* List of bootstrap peers; defaults to the IPFS DHT peers
* Array[Maddr String]
* `[]`
* `DHT`
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps it should be its own sub object. its absence represents it being disabled. even if it only has one or two options to start. thoughts?

config/config.go Outdated
return nil
}

type bootstrap struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

feels like these should be public, but i'm open to suggestion!

Copy link
Collaborator

Choose a reason for hiding this comment

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

second that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a reason as to why? My thought was that they were only being used internally for marshaling

Copy link
Collaborator

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

Command line options should not be ignored when there is a config, but rather override options.

config/config.go Outdated
return err
}
jma := JSONMaddr{ma}
jm = &jma
Copy link
Collaborator

Choose a reason for hiding this comment

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

just jm = &JSONMaddr(ma}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

config/config.go Outdated
return nil
}

type bootstrap struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

second that.

if err := json.Unmarshal(body, c); err != nil {
log.Fatal(err)
}
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

we need to allow command line options to override the config.

Copy link
Contributor

Choose a reason for hiding this comment

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

i think we could make that in another change, so long as we note the behavior in the readme. maybe we just make an issue for that to support config merging. this would be a big help in the meantime

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should do it here, it's a pretty simple thing to do. It would be very surprising to pass options that are ignored when also passing a config.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good let’s do overrides

Copy link
Contributor

@bigs bigs left a comment

Choose a reason for hiding this comment

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

great work, thanks for taking this on. just a few changes requested

p2pd/main.go Outdated
if err != nil {
log.Fatal(err)
}
if err := json.Unmarshal(body, c); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

i think this (and the instance below) should be &c

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah right

if err := json.Unmarshal(body, c); err != nil {
log.Fatal(err)
}
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

i think we could make that in another change, so long as we note the behavior in the readme. maybe we just make an issue for that to support config merging. this would be a big help in the meantime

{
"ListenAddr": "/unix/tmp/p2pd.sock",
"Quiet": false,
"ID": "",
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe rather than having this be a "default" example have it be a "complete" example with all of the fields filled in. as a developer, i find those a lot more helpful, because it lets me know what options are possible at a glance! obv the schema does this, but i think that's useful. we could include the "default" config below it, with empty options elided as suggested.

@mvid
Copy link
Contributor Author

mvid commented Apr 18, 2019 via email

@vyzo
Copy link
Collaborator

vyzo commented Apr 18, 2019

Is it possible to make flags order dependent in Go?

not that I know of.

@mvid
Copy link
Contributor Author

mvid commented Apr 19, 2019

@bigs relay, pubsub, connectionManager and bootstrap all have Enabled fields in their subobjects. In theory they could all be replaced with subobject existence instead. I feel like being explicit is better though. Right now you need to pass the enabled flag for any of the subflags to be used

@bigs
Copy link
Contributor

bigs commented Apr 22, 2019

@mvid i like the explicit nature, let's keep it. let's do the command line overrides and merge this

@mvid
Copy link
Contributor Author

mvid commented Apr 23, 2019

@bigs ok, it now overrides with flags

Copy link
Contributor

@bigs bigs 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

@bigs bigs merged commit 6f4d625 into master Apr 23, 2019
@ghost ghost removed the in progress label Apr 23, 2019
@bigs bigs deleted the spec/config branch April 23, 2019 21:38
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.

6 participants