-
Notifications
You must be signed in to change notification settings - Fork 973
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
Changes from 13 commits
1153e2c
ba9e6dc
184bb5c
4e19d2e
93baa1f
b0a990e
d6a365c
710e118
6dc09f5
e4c8682
f7e67ea
8193dce
6093a61
af15543
4763525
6d02a86
98606d5
90fa357
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,63 @@ | ||
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/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", | ||
shardingCommand = cli.Command{ | ||
Action: utils.MigrateFlags(sharding), | ||
Name: "sharding", | ||
Usage: "Start a sharding-enabled node", | ||
ArgsUsage: "[endpoint]", | ||
Flags: []cli.Flag{utils.DataDirFlag, utils.PasswordFileFlag, utils.NetworkIdFlag, utils.IPCPathFlag, utils.DepositFlag}, | ||
Flags: []cli.Flag{utils.ActorFlag, 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", | ||
ArgsUsage: "[endpoint]", | ||
Flags: []cli.Flag{utils.DataDirFlag, utils.PasswordFileFlag, utils.NetworkIdFlag, utils.IPCPathFlag}, | ||
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() | ||
// sharding 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 sharding(ctx *cli.Context) error { | ||
// configures a sharding-enabled node using the cli's context. | ||
shardingNode := node.NewNode(ctx) | ||
registerShardingServices(shardingNode) | ||
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.
|
||
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(ctx *cli.Context) (sharding.Service, error) { | ||
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.
|
||
if actorFlag == "notary" { | ||
return notary.NewNotary(n.Context(), n) | ||
} else if actorFlag == "proposer" { | ||
return proposer.NewProposer(n.Context(), 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.Context(), 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 | ||
} |
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. |
||
} | ||
) | ||
|
||
|
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