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

Tentative of a cli template #54

Merged
merged 5 commits into from
May 29, 2020
Merged

Tentative of a cli template #54

merged 5 commits into from
May 29, 2020

Conversation

Gilthoniel
Copy link
Contributor

This PR implements a tentative of a CLI template for the modules to follow to implement their own controllers that can be chosen before compiling an ledger application.

Also: implement a controller to create a network of nodes with grpc

@Gilthoniel Gilthoniel added the mod/mino About the Mino module label May 27, 2020
@Gilthoniel Gilthoniel self-assigned this May 27, 2020
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 95.094% when pulling 2c2cc0f on initial_cmd into eb1ab9a on master.

@Gilthoniel
Copy link
Contributor Author

example

With nodes started using: memcoin --socket /tmp/node1.sock start --port 2000

@Gilthoniel Gilthoniel requested a review from nkcr May 28, 2020 07:27
@Gilthoniel Gilthoniel added the R4M 🚀 The PR is ready to be reviewed and merged label May 28, 2020
Copy link
Contributor

@nkcr nkcr left a comment

Choose a reason for hiding this comment

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

That was a big chunk, we should have a call tomorrow to talk about it.

cmd/mod.go Outdated

// Controller is the interface to implement to enable commands specific to
// the ledger implementation.
type Controller interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Per se the name "controller" is correct, but for me it has more the meaning of the link beween a model and its representation in an MVC pattern. Maybe just CLI ?

cmd/mod.go Outdated
Run(Context, Injector) error
}

// Request is a context to handle commands sent to the daemon.
Copy link
Contributor

Choose a reason for hiding this comment

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

"Request is a context": very confusing since there is exactly a "Context" struct bellow. So maybe update the comment or the Context struct? Because there is a lot of different part in this package it is hard to see what would be THE Context. So maybe Context should be RunContext or something like that.

cmd/mod.go Outdated
Out io.Writer
}

// Context is provide to an action to read the flags.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Context is provide to an action to read the flags.
// Context is provided to an action to read the flags.

cmd/mod.go Outdated
Execute(Request) error
}

// Builder defines how to build a list of commands to tweak the ledger.
Copy link
Contributor

Choose a reason for hiding this comment

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

"...to tweak the ledger" ?

EDIT: ok, didn't realize this abstraction was tight to a ledger configuration. I was under the impression that this abstraction would be totally independent and general-purpose.

cmd/app.go Outdated
}

// SocketDaemon is a daemon using UNIX socket. This allows the permissions to be
// manage by the filesystem. A user must have read/write access to send a
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// manage by the filesystem. A user must have read/write access to send a
// managed by the filesystem. A user must have read/write access to send a


msg := &Certificate{Address: text, Value: cert}

// Prepare the list of send back to the new node.
Copy link
Contributor

Choose a reason for hiding this comment

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

it's too late for me to rephrase it, but it seems that a word should be changed.


func (o overlayServer) Share(ctx context.Context, msg *Certificate) (*CertificateAck, error) {
// TODO: verify the validity of the certificate by connecting to the distant
// node by that requires a protection against malicious share.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// node by that requires a protection against malicious share.
// node but that requires a protection against malicious share.

Comment on lines 1 to 2
// Package tokens defines a token holder to generate and validate access tokens.
// and provides an implementation in-memory.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Package tokens defines a token holder to generate and validate access tokens.
// and provides an implementation in-memory.
// Package tokens defines a token holder to generate and validate access tokens
// and provides an in-memory implementation.

}

// Verify implements tokens.Holder. It returns true if the token is valid.
func (holder *InMemoryHolder) Verify(token string) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't the token also store the node address it has been issued to? Right now someone could potentially eave drop on the network, stole the token and use it. Verify would then be

Verify(token string, origin mino.Address)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure where you can eavesdrop as the request is sent over TLS.

@@ -319,6 +461,7 @@ func makeCertificate() (*tls.Certificate, error) {

tmpl := &x509.Certificate{
SerialNumber: big.NewInt(1),
DNSNames: []string{},
Copy link
Contributor

Choose a reason for hiding this comment

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

Not used.. yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my mistake

@Gilthoniel
Copy link
Contributor Author

@nkcr Thanks a lot, I wasn't super happy with the abstraction but it now looks much better. I changed one thing from our discussion this morning which is the Action for a node builder that is now a ActionTemplate that you transformed into an actual action which allows to have the abstraction at the top level.

@Gilthoniel Gilthoniel requested a review from nkcr May 29, 2020 13:17
Copy link
Contributor

@nkcr nkcr left a comment

Choose a reason for hiding this comment

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

Very nice! I'm a fan of those package comments 😄
LGTM 🚀

@Gilthoniel Gilthoniel merged commit 49a83f5 into master May 29, 2020
@Gilthoniel Gilthoniel deleted the initial_cmd branch May 29, 2020 13:57
bbjubjub2494 pushed a commit to bbjubjub2494/dela that referenced this pull request Aug 3, 2024
Tentative of a cli template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mod/mino About the Mino module R4M 🚀 The PR is ready to be reviewed and merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants