working on sharding entrypoint

Former-commit-id: 50c0ab4bad92d27bf980e83e64088940544e94c2 [formerly 5dbfb91e925f14a743390f7da6bb2db1a30371db]
Former-commit-id: 66fb852ec273f74baaaf25b5a80987ac284c56ee
This commit is contained in:
Preston Van Loon 2018-01-14 19:10:02 -05:00
parent 95efe2c78d
commit 9b6f224f83
6 changed files with 103 additions and 0 deletions

View File

@ -164,6 +164,8 @@ func init() {
consoleCommand, consoleCommand,
attachCommand, attachCommand,
javascriptCommand, javascriptCommand,
// See shardingcmd.go:
shardingClientCommand,
// See misccmd.go: // See misccmd.go:
makecacheCommand, makecacheCommand,
makedagCommand, makedagCommand,

30
cmd/geth/shardingcmd.go Normal file
View File

@ -0,0 +1,30 @@
package main
import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/sharding"
"github.com/ethereum/go-ethereum/cmd/utils"
cli "gopkg.in/urfave/cli.v1"
)
var (
shardingClientCommand = cli.Command{
Action: utils.MigrateFlags(shardingClient),
Name: "shard",
Usage: "Start a sharding client",
ArgsUsage: "[endpoint]",
Category: "SHARDING COMMANDS",
Description: "TODO(prestonvanloon)- Add sharding client description",
}
)
func shardingClient(ctx *cli.Context) error {
log.Info("hello world!")
c := sharding.MakeShardingClient(ctx)
if err := c.Start(); err != nil {
return err
}
c.Wait()
return nil
}

29
sharding/client.go Normal file
View File

@ -0,0 +1,29 @@
package sharding
import (
"github.com/ethereum/go-ethereum/log"
cli "gopkg.in/urfave/cli.v1"
)
type Client struct {
}
func MakeShardingClient(ctx *cli.Context) *Client {
// TODO: Setup client
return &Client{}
}
func (c *Client) Start() error {
log.Info("Starting sharding client")
// TODO: Dial to RPC
// TODO: Verify VMC
if err := c.verifyVMC(); err != nil {
return err
}
return nil
}
func (c *Client) Wait() {
// TODO: Blocking lock
}

18
sharding/config.go Normal file
View File

@ -0,0 +1,18 @@
package sharding
import "math/big"
var (
// Number of network shards
shardCount = 100
// Address of the validator management contract
validatorManagerAddress = "" // TODO
// Gas limit for verifying signatures
sigGasLimit = 40000
// Number of blocks in a period
periodLength = 5
// Number of periods to lookahead for ??? TODO(prestonvanloon) finish this comment.
lookaheadPeriods = 4
// Required deposit size in wei
depositSize = new(big.Int).Exp(big.NewInt(10), big.NewInt(20), nil) // 100 ETH
)

16
sharding/config_test.go Normal file
View File

@ -0,0 +1,16 @@
package sharding
import (
"math/big"
"testing"
)
func TestDepositSize(t *testing.T) {
want, err := new(big.Int).SetString("100000000000000000000", 10) // 100 ETH
if !err {
t.Fatalf("Failed to setup test")
}
if depositSize.Cmp(want) != 0 {
t.Errorf("depositSize incorrect. Wanted %d, got %d", want, depositSize)
}
}

8
sharding/vmc.go Normal file
View File

@ -0,0 +1,8 @@
package sharding
func (c *Client) verifyVMC() error {
// TODO: Fetch validator manager contract.
// TODO: Assert that the contract contents/ABI are as expected.
// TODO: Upload VMC if does not exist.
return nil
}