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

Setup a Simple libp2p Echo Server as a Service Attached to Sharding Node #129

Closed
rauljordan opened this issue May 22, 2018 · 3 comments
Closed
Labels
Help Wanted Extra attention is needed
Milestone

Comments

@rauljordan
Copy link
Contributor

Hi all,

As a simple way to integrate libp2p and to begin our experimentation of libp2p into our repo, we can start by setting up a bootnode that serves a simple echo server, and attach another libp2p node to our sharding node as a Service (see #127). Let's keep this constrained a package called p2p under the sharding package in our repo.

We can register this echo service in the registerShardingServices func in cmd/geth/shardingcmd.go

// registerShardingServices sets up either a notary or proposer
// sharding service dependent on the ClientType cli flag. We should be defining
// the services we want to register here, as this is the geth command entry point
// for sharding.
func registerShardingServices(n node.Node) error {
	protocolFlag := n.Context().GlobalString(utils.ProtocolFlag.Name)

	err := n.Register(func(ctx *cli.Context) (sharding.Service, error) {
		// TODO(terenc3t): handle case when we just want to start an observer node.
		if protocolFlag == "notary" {
			return notary.NewNotary(n.Context(), n)
		}
		return proposer.NewProposer(n.Context(), n)
	})

	if err != nil {
		return fmt.Errorf("failed to register the main sharding services: %v", err)
	}

	// TODO: registers the shardp2p service.
	// we can do n.Register and initialize a shardp2p.NewServer() or something like that.
	return nil
}

Then, in the submit collation function of the notary package, as the notary protocol will have access to the sharding node, we can call out an echo request using this shardp2p service and get an output.

What This Achieves

This would at least allow us to get our hands dirty with libp2p and see how we can write useful functions we can call throughout our notary or proposer protocols. This code will eventually evolve into registering another service in the sharding node for discovery, and more.

@rauljordan rauljordan added Help Wanted Extra attention is needed Phase 1 labels May 22, 2018
@rauljordan rauljordan added this to the Ruby milestone May 22, 2018
@rauljordan
Copy link
Contributor Author

Could be interesting to check out the work done in other PR's like: ethereum/go-ethereum#16419

@terencechain
Copy link
Member

terencechain commented May 22, 2018

I'm also interested in the development of this: libp2p/libp2p#33

@rauljordan
Copy link
Contributor Author

#149 simplifies this immensely, as this can be constrained to the p2p subpackage in the sharding package and attached as a service to ShardEthereum

Redidacove pushed a commit to Redidacove/prysm that referenced this issue Aug 13, 2024
* Update development-updates.md

Week 1 Update

* Update development-updates.md

Hey I have adjusted it according to the markdown

* Update development-updates.md

Adjusted

* Update development-updates.md

updated according to markdown

* Update development-updates.md

.

* Update development-updates.md

adjusted according to markdown

* Update development-updates.md

..

* Update development-updates.md

..

* Update development-updates.md

..

* Update development-updates.md

---------

Co-authored-by: Mário Havel <61149543+taxmeifyoucan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants