-
Notifications
You must be signed in to change notification settings - Fork 980
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
Rearchitecting the Sharding Node, its Lifecycle, and Services #127
Merged
Merged
Changes from 15 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
1153e2c
sharding: revamp sharding client config to single entrypoint
rauljordan ba9e6dc
sharding: simplified newclient func
rauljordan 184bb5c
sharding: rename client package to node
rauljordan 4e19d2e
sharding: refactor proposers
rauljordan 93baa1f
sharding: tests pass
rauljordan b0a990e
sharding: fixed main entry point, linter errors
rauljordan d6a365c
sharding: fully functional start func in notary service
rauljordan 710e118
sharding: travis passes, all entrypoints work, notary protocol working
rauljordan 6dc09f5
sharding: merge changes from #124 in master
rauljordan e4c8682
sharding: update documentation to reflect new entry points
rauljordan f7e67ea
sharding: elim unnecessary comment
rauljordan 8193dce
sharding: address review comments, add observer package
rauljordan 6093a61
sharding: edit documentation
rauljordan af15543
sharding: addressed comments, linters pass
rauljordan 4763525
sharding: address terence comment
rauljordan 6d02a86
sharding: fetch master changes
rauljordan 98606d5
sharding: address comments, elim string references
rauljordan 90fa357
sharding: return err
rauljordan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,66 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/ethereum/go-ethereum/sharding/notary" | ||
"github.com/ethereum/go-ethereum/sharding/proposer" | ||
"fmt" | ||
|
||
"github.com/ethereum/go-ethereum/cmd/utils" | ||
"github.com/ethereum/go-ethereum/sharding" | ||
"github.com/ethereum/go-ethereum/sharding/node" | ||
"github.com/ethereum/go-ethereum/sharding/notary" | ||
"github.com/ethereum/go-ethereum/sharding/observer" | ||
"github.com/ethereum/go-ethereum/sharding/proposer" | ||
cli "gopkg.in/urfave/cli.v1" | ||
) | ||
|
||
var ( | ||
notaryClientCommand = cli.Command{ | ||
Action: utils.MigrateFlags(notaryClient), | ||
Name: "sharding-notary", | ||
Aliases: []string{"shard-notary"}, | ||
Usage: "Start a sharding notary client", | ||
ArgsUsage: "[endpoint]", | ||
Flags: []cli.Flag{utils.DataDirFlag, utils.PasswordFileFlag, utils.NetworkIdFlag, utils.IPCPathFlag, utils.DepositFlag}, | ||
Category: "SHARDING COMMANDS", | ||
Description: ` | ||
Launches a sharding notary client that connects to a running geth node and submit collations to a Sharding Manager Contract. This feature is a work in progress. | ||
`, | ||
} | ||
proposerClientCommand = cli.Command{ | ||
Action: utils.MigrateFlags(proposerClient), | ||
Name: "sharding-proposer", | ||
Aliases: []string{"shard-proposer"}, | ||
Usage: "Start a sharding proposer client", | ||
shardingCommand = cli.Command{ | ||
Action: utils.MigrateFlags(shardingCmd), | ||
Name: "sharding", | ||
Usage: "Start a sharding-enabled node", | ||
ArgsUsage: "[endpoint]", | ||
Flags: []cli.Flag{utils.DataDirFlag, utils.PasswordFileFlag, utils.NetworkIdFlag, utils.IPCPathFlag}, | ||
Flags: []cli.Flag{utils.ActorFlag, utils.DataDirFlag, utils.PasswordFileFlag, utils.NetworkIdFlag, utils.IPCPathFlag, utils.DepositFlag}, | ||
Category: "SHARDING COMMANDS", | ||
Description: ` | ||
Launches a sharding proposer client that connects to a running geth node and proposes collations to notary node. This feature is a work in progress. | ||
Launches a sharding node that manages services related to submitting collations to a Sharding Manager Contract, notary and proposer services, and shardp2p connections. This feature is a work in progress. | ||
`, | ||
} | ||
) | ||
|
||
func notaryClient(ctx *cli.Context) error { | ||
c := notary.NewNotary(ctx) | ||
return c.Start() | ||
// shardingCmd is the main cmd line entry point for starting a sharding-enabled node. | ||
// A sharding node launches a suite of services including notary services, | ||
// proposer services, and a shardp2p protocol. | ||
func shardingCmd(ctx *cli.Context) error { | ||
// configures a sharding-enabled node using the cli's context. | ||
shardingNode := node.NewNode(ctx) | ||
if err := registerShardingServices(shardingNode); err != nil { | ||
return fmt.Errorf("could not start sharding node: %v", err) | ||
} | ||
defer shardingNode.Close() | ||
// starts a connection to a geth node and kicks off every registered service. | ||
return shardingNode.Start() | ||
} | ||
|
||
func proposerClient(ctx *cli.Context) error { | ||
p := proposer.NewProposer(ctx) | ||
return p.Start() | ||
// 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 { | ||
actorFlag := n.Context().GlobalString(utils.ActorFlag.Name) | ||
|
||
err := n.Register(func() (sharding.Service, error) { | ||
if actorFlag == "notary" { | ||
return notary.NewNotary(n) | ||
} else if actorFlag == "proposer" { | ||
return proposer.NewProposer(n) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make this instead if we will be having observer nodes
|
||
return observer.NewObserver(n) | ||
}) | ||
|
||
if err != nil { | ||
return fmt.Errorf("failed to register the main sharding services: %v", err) | ||
} | ||
|
||
// TODO(prestonvanloon) registers the shardp2p service. | ||
// we can do n.Register and initialize a shardp2p.NewServer() or something like that. | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -533,11 +533,14 @@ var ( | |
Usage: "Minimum POW accepted", | ||
Value: whisper.DefaultMinimumPoW, | ||
} | ||
|
||
//Sharding Settings | ||
// Sharding Settings | ||
DepositFlag = cli.BoolFlag{ | ||
Name: "deposit", | ||
Usage: "To become a notary with your sharding client, " + new(big.Int).Div(sharding.NotaryDeposit, new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)).String() + " ETH will be deposited into SMC", | ||
Usage: "To become a notary in a sharding node, " + new(big.Int).Div(sharding.NotaryDeposit, new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)).String() + " ETH will be deposited into SMC", | ||
} | ||
ActorFlag = cli.StringFlag{ | ||
Name: "actor", | ||
Usage: `use the --actor "notary" or --actor "proposer" to start a notary or proposer service in the sharding node. If omitted, the sharding node registers an Observer service that simply observes the activity in the sharded network`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You shouldn't need the quotes for a flag value. It's fine but FYI. |
||
} | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can put a short para explaining that if they launch the sharding node without the protocol flag, an observer node is launched instead
geth sharding --datadir /path/to/your/datadir --password /path/to/your/password.txt --networkid 12345