add localnet genesis

This commit is contained in:
elizabeth 2023-03-29 17:48:13 -04:00
parent 3c478d770d
commit eadb768025
4 changed files with 40 additions and 5 deletions

View file

@ -1229,9 +1229,9 @@ func setHTTP(ctx *cli.Context, cfg *node.Config) {
} }
} }
// setGRCP creates the gRPC RPC listener interface string from the set command // setGRPC creates the gRPC RPC listener interface string from the set command
// line flags, returning empty if the gRPC endpoint is disabled. // line flags, returning empty if the gRPC endpoint is disabled.
func setGRCP(ctx *cli.Context, cfg *node.Config) { func setGRPC(ctx *cli.Context, cfg *node.Config) {
if ctx.Bool(GRPCEnabledFlag.Name) { if ctx.Bool(GRPCEnabledFlag.Name) {
if ctx.IsSet(GRPCHostFlag.Name) { if ctx.IsSet(GRPCHostFlag.Name) {
cfg.GRPCHost = ctx.String(GRPCHostFlag.Name) cfg.GRPCHost = ctx.String(GRPCHostFlag.Name)
@ -1491,7 +1491,7 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
SetP2PConfig(ctx, &cfg.P2P) SetP2PConfig(ctx, &cfg.P2P)
setIPC(ctx, cfg) setIPC(ctx, cfg)
setHTTP(ctx, cfg) setHTTP(ctx, cfg)
setGRCP(ctx, cfg) setGRPC(ctx, cfg)
setGraphQL(ctx, cfg) setGraphQL(ctx, cfg)
setWS(ctx, cfg) setWS(ctx, cfg)
setNodeUserIdent(ctx, cfg) setNodeUserIdent(ctx, cfg)

21
genesis.json Normal file
View file

@ -0,0 +1,21 @@
{
"config": {
"chainId": 1337,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"ethash": {}
},
"difficulty": "10000",
"gasLimit": "8000000",
"alloc": {
"0x46B77EFDFB20979E1C29ec98DcE73e3eCbF64102": { "balance": "300000000000000000000" }
}
}

View file

@ -533,7 +533,7 @@ func (n *Node) stopRPC() {
} }
func (n *Node) startGRPC() error { func (n *Node) startGRPC() error {
if n.config.GRPCHost != "" { if n.grpcServerHandler != nil {
// start the server // start the server
if err := n.grpcServerHandler.Start(); err != nil { if err := n.grpcServerHandler.Start(); err != nil {
return err return err
@ -544,8 +544,10 @@ func (n *Node) startGRPC() error {
} }
func (n *Node) stopGRPC() { func (n *Node) stopGRPC() {
if n.grpcServerHandler != nil {
n.grpcServerHandler.Stop() n.grpcServerHandler.Stop()
} }
}
// startInProc registers all RPC APIs on the inproc server. // startInProc registers all RPC APIs on the inproc server.
func (n *Node) startInProc(apis []rpc.API) error { func (n *Node) startInProc(apis []rpc.API) error {

12
private_network.md Normal file
View file

@ -0,0 +1,12 @@
# private network
1. Make a new account in Metamask (or whichever method you prefer). Copy paste the address into `genesis.json`'s `alloc` field. This account will be allocated 300 ETH at startup.
2. Replace the etherbase in the following with your account (it doesn't really matter though, since mining doesn't require signing). Then, run:
```bash
make geth
./build/bin/geth --datadir ~/.astriageth/ init genesis.json
./build/bin/geth --datadir ~/.astriageth/ --http --http.port=8545 --ws --ws.port=8545 --networkid=1337 --http.corsdomain='*' --ws.origins='*' --mine --miner.threads 1 --miner.etherbase=0xDB8c0F738639Da247bC67251548a186b2107bf4d
```
4. Open up Metamask and go to the Localhost 8545 network. You should see your account has 300 ETH. You can now transfer this to other accounts.