mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-11 00:18:06 -05:00
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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
9
sharding/contracts/README.md
Normal file
9
sharding/contracts/README.md
Normal 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
|
||||
|
||||
```
|
||||
880
sharding/contracts/validator_manager.go
Normal file
880
sharding/contracts/validator_manager.go
Normal file
File diff suppressed because one or more lines are too long
125
sharding/vmc.go
125
sharding/vmc.go
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user