Merge pull request #13 from prestonvanloon/sharding

Use generated go bindings for validator management contract

Former-commit-id: cad5e473a71bc8ad0689018cc65883e409126c68 [formerly 56409d4ca269dad701534c2136a086095d6d7291]
Former-commit-id: ab885a8d678cdbc5536fadab09b8f8704f973749
This commit is contained in:
Raul Jordan
2018-01-28 15:02:35 -06:00
committed by GitHub
5 changed files with 943 additions and 97 deletions

View File

@@ -12,6 +12,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/sharding/contracts"
cli "gopkg.in/urfave/cli.v1"
)
@@ -25,6 +26,7 @@ type Client struct {
client *ethclient.Client // Ethereum RPC client.
keystore *keystore.KeyStore // Keystore containing the single signer
ctx *cli.Context // Command line context
vmc *contracts.VMC // The deployed validator management contract
}
// MakeShardingClient for interfacing with geth full node.
@@ -66,7 +68,7 @@ func (c *Client) Start() error {
}
c.client = ethclient.NewClient(rpcClient)
defer rpcClient.Close()
if err := c.verifyVMC(); err != nil {
if err := initVMC(c); err != nil {
return err
}

View File

@@ -7,6 +7,7 @@ import (
"math/big"
"math/rand"
"os"
"path"
"sync"
"testing"
@@ -44,12 +45,18 @@ func (s *FakeEthService) SetGetCode(resp hexutil.Bytes, err error) {
s.mu.Unlock()
}
func (s *FakeEthService) GasPrice(ctx context.Context) (*big.Int, error) {
return big.NewInt(10000), nil
func (s *FakeEthService) GasPrice(ctx context.Context) (hexutil.Big, error) {
b := big.NewInt(1000)
return hexutil.Big(*b), nil
}
func (s *FakeEthService) GetTransactionCount(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (*hexutil.Uint64, error) {
return nil, nil
func (s *FakeEthService) EstimateGas(ctx context.Context, msg interface{}) (hexutil.Uint64, error) {
h := hexutil.Uint64(uint64(1000000))
return h, nil
}
func (s *FakeEthService) GetTransactionCount(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (hexutil.Uint64, error) {
return hexutil.Uint64(uint64(1)), nil
}
func (s *FakeEthService) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error) {
@@ -74,11 +81,6 @@ func (s *FakeNetworkService) Version() (string, error) {
}
func newTestServer(endpoint string) (*rpc.Server, error) {
// Create datadir.
if err := os.Mkdir(endpoint, 0777); err != nil {
return nil, err
}
// Create a default account without password.
scryptN, scryptP, keydir, err := (&node.Config{DataDir: endpoint}).AccountConfig()
if err != nil {
@@ -112,7 +114,7 @@ func createContext() *cli.Context {
}
func TestShardingClient(t *testing.T) {
endpoint := fmt.Sprintf("%s/go-ethereum-test-ipc-%d-%d", os.TempDir(), os.Getpid(), rand.Int63())
endpoint := path.Join(os.TempDir(), fmt.Sprintf("go-ethereum-test-ipc-%d-%d", os.Getpid(), rand.Int63()))
server, err := newTestServer(endpoint)
if err != nil {
t.Fatalf("Failed to create a test server: %v", err)

View File

@@ -0,0 +1,9 @@
# Sharding contracts
Generate contract bindings from this directory:
```bash
go run ../../cmd/abigen/main.go --sol validator_manager.sol --pkg contracts --out validator_manager.go
```

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long