mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 18:51:19 +00:00
merge
Former-commit-id: 9a827718c867cff1f883fbf1180e9197120abf07 [formerly 7ab3553c16ba1c0c90d2427a7876c70f16e71d27] Former-commit-id: 17e39b7cdeff91ff22c33e9aaeb21f6aac35e89d
This commit is contained in:
commit
ec79a87ed9
@ -7,12 +7,9 @@ This repository contains the sharding implementation for the go-ethereum client.
|
||||
To get started with running the project, follow the instructions to initialize your own private Ethereum blockchain and geth node:
|
||||
|
||||
```
|
||||
$ git clone github.com/prysmaticlabs/geth-sharding
|
||||
$ make geth
|
||||
$ cd $GOPATH/src/github.com/prysmaticlabs/geth-sharding
|
||||
$ make geth
|
||||
$ ./build/bin/geth init ./sharding/genesis.json -datadir /path/to/your/datadir
|
||||
$ ./build/bin/geth --nodiscover console --datadir /path/to/your/datadir
|
||||
$ ./build/bin/geth --nodiscover console --datadir /path/to/your/datadir --networkid 12345
|
||||
```
|
||||
|
||||
Then, the geth console can start up and you can start a miner as follows:
|
||||
@ -29,10 +26,10 @@ Then, once you are satisfied with mining for a few seconds, stop the miner with
|
||||
> miner.stop()
|
||||
```
|
||||
|
||||
Once you have this private geth node running on your local network, the sharding client can be started as a standalone geth command as follows in a separate terminal window:
|
||||
Now, save the passphrase you used in the geth node into a text file called `password.txt`. Then, once you have this private geth node running on your local network, the sharding client can be started as a standalone geth command as follows in a separate terminal window:
|
||||
|
||||
```
|
||||
$ geth sharding /path/to/your/datadir/geth.ipc
|
||||
$ ./build/bin/geth shard --datadir=/path/to/your/datadir --password=password.txt
|
||||
```
|
||||
|
||||
The project consists of the following parts, with each of them requiring comprehensive tests:
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -44,12 +44,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) {
|
||||
@ -67,6 +73,12 @@ func (s *FakeEthService) GetTransactionByHash(hash common.Hash) (tx *types.Trans
|
||||
return nil, false, nil
|
||||
}
|
||||
|
||||
type FakeNetworkService struct{}
|
||||
|
||||
func (s *FakeNetworkService) Version() (string, error) {
|
||||
return "100", nil
|
||||
}
|
||||
|
||||
func newTestServer(endpoint string) (*rpc.Server, error) {
|
||||
// Create datadir.
|
||||
if err := os.Mkdir(endpoint, 0777); err != nil {
|
||||
@ -87,6 +99,9 @@ func newTestServer(endpoint string) (*rpc.Server, error) {
|
||||
if err := server.RegisterName("eth", new(FakeEthService)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := server.RegisterName("net", new(FakeNetworkService)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
l, err := rpc.CreateIPCListener(endpoint + "/geth.ipc")
|
||||
if err != nil {
|
||||
return nil, 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
Loading…
Reference in New Issue
Block a user