From eadb7680252b6690c31e763a5a6389068fbbbf26 Mon Sep 17 00:00:00 2001 From: elizabeth Date: Wed, 29 Mar 2023 17:48:13 -0400 Subject: [PATCH] add localnet genesis --- cmd/utils/flags.go | 6 +++--- genesis.json | 21 +++++++++++++++++++++ node/node.go | 6 ++++-- private_network.md | 12 ++++++++++++ 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 genesis.json create mode 100644 private_network.md diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 02bb9f2672..2b16231d1e 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -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. -func setGRCP(ctx *cli.Context, cfg *node.Config) { +func setGRPC(ctx *cli.Context, cfg *node.Config) { if ctx.Bool(GRPCEnabledFlag.Name) { if ctx.IsSet(GRPCHostFlag.Name) { cfg.GRPCHost = ctx.String(GRPCHostFlag.Name) @@ -1491,7 +1491,7 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) { SetP2PConfig(ctx, &cfg.P2P) setIPC(ctx, cfg) setHTTP(ctx, cfg) - setGRCP(ctx, cfg) + setGRPC(ctx, cfg) setGraphQL(ctx, cfg) setWS(ctx, cfg) setNodeUserIdent(ctx, cfg) diff --git a/genesis.json b/genesis.json new file mode 100644 index 0000000000..0669d58c45 --- /dev/null +++ b/genesis.json @@ -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" } + } + } \ No newline at end of file diff --git a/node/node.go b/node/node.go index e13dd2f8e3..fe1b17592b 100644 --- a/node/node.go +++ b/node/node.go @@ -533,7 +533,7 @@ func (n *Node) stopRPC() { } func (n *Node) startGRPC() error { - if n.config.GRPCHost != "" { + if n.grpcServerHandler != nil { // start the server if err := n.grpcServerHandler.Start(); err != nil { return err @@ -544,7 +544,9 @@ func (n *Node) startGRPC() error { } func (n *Node) stopGRPC() { - n.grpcServerHandler.Stop() + if n.grpcServerHandler != nil { + n.grpcServerHandler.Stop() + } } // startInProc registers all RPC APIs on the inproc server. diff --git a/private_network.md b/private_network.md new file mode 100644 index 0000000000..1b9bb03e72 --- /dev/null +++ b/private_network.md @@ -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. \ No newline at end of file