|
|
# Instalación de una red con un solo nodo
|
|
|
Es posible instalar una red con un solo nodo, a los efectos de testeo o desarrollo.
|
|
|
|
|
|
Se asume que ya está instalado `geth`, pero por ejemplo en Ubuntu se puede instalar con:
|
|
|
|
|
|
```
|
|
|
sudo add-apt-repository -y ppa:ethereum/ethereum
|
|
|
sudo apt-get update
|
|
|
sudo apt-get install ethereum
|
|
|
```
|
|
|
|
|
|
```
|
|
|
$ geth version
|
|
|
Geth
|
|
|
Version: 1.8.14-stable
|
|
|
Git Commit: 316fc7ecfc10d06603f1358c1f4c1020ec36dd2a
|
|
|
Architecture: amd64
|
|
|
Protocol Versions: [63 62]
|
|
|
Network Id: 1
|
|
|
Go Version: go1.10.1
|
|
|
Operating System: linux
|
|
|
GOPATH=
|
|
|
GOROOT=/usr/lib/go-1.10
|
|
|
```
|
|
|
|
|
|
## Creación de directorios
|
|
|
|
|
|
A modo de ejemplo, crearemos un directorio `devnet`, dentro del cual existirá un subdirectorio `network`, que albergará un directorio por nodo (en este caso uno solo, llamado `node`).
|
|
|
```
|
|
|
$ mkdir -p devnet/network/node
|
|
|
```
|
|
|
## Creación de cuentas
|
|
|
Debe crearse al menos una cuenta.
|
|
|
|
|
|
```
|
|
|
$ cd devnet
|
|
|
devnet$ geth --datadir network/node account new
|
|
|
INFO [10-11|11:36:05.231] Maximum peer count ETH=25 LES=0 total=25
|
|
|
Your new account is locked with a password. Please give a password. Do not forget this password.
|
|
|
Passphrase:
|
|
|
Repeat passphrase:
|
|
|
Address: {10c69b29d6f1bedc6fb97758f74a9f64eb2e7694}
|
|
|
```
|
|
|
|
|
|
En este caso la dirección de la cuenta es `0x10c69b29d6f1bedc6fb97758f74a9f64eb2e7694`. La dirección también puede obtenerse de la última parte del nombre del archivo correspondiente en el directorio `node/keystore/`
|
|
|
|
|
|
```
|
|
|
~/devnet$ ls network/node/keystore/
|
|
|
UTC--2018-10-11T14-36-07.790871325Z--10c69b29d6f1bedc6fb97758f74a9f64eb2e7694
|
|
|
```
|
|
|
La _passphrase_ solicitada se puede dejar vacía.
|
|
|
|
|
|
En los ejemplos de los pasos siguientes, debe reemplazarse la dirección `0x10c69b29d6f1bedc6fb97758f74a9f64eb2e7694` por la que se haya generado en el nodo a crear.
|
|
|
|
|
|
## Creación del bloque génesis e inicialización de la red
|
|
|
|
|
|
Usaremos el programa `puppeth`, parte de `geth`:
|
|
|
|
|
|
```
|
|
|
devnet$ puppeth
|
|
|
+-----------------------------------------------------------+
|
|
|
| Welcome to puppeth, your Ethereum private network manager |
|
|
|
| |
|
|
|
| This tool lets you create a new Ethereum network down to |
|
|
|
| the genesis block, bootnodes, miners and ethstats servers |
|
|
|
| without the hassle that it would normally entail. |
|
|
|
| |
|
|
|
| Puppeth uses SSH to dial in to remote servers, and builds |
|
|
|
| its network components out of Docker containers using the |
|
|
|
| docker-compose toolset. |
|
|
|
+-----------------------------------------------------------+
|
|
|
|
|
|
Please specify a network name to administer (no spaces or hyphens, please)
|
|
|
> devnet
|
|
|
|
|
|
Sweet, you can set this via --network=devnet next time!
|
|
|
|
|
|
INFO [10-11|11:40:40.128] Administering Ethereum network name=devnet
|
|
|
WARN [10-11|11:40:40.129] No previous configurations found path=/home/miguel/.puppeth/devnet
|
|
|
|
|
|
What would you like to do? (default = stats)
|
|
|
1. Show network stats
|
|
|
2. Configure new genesis
|
|
|
3. Track new remote server
|
|
|
4. Deploy network components
|
|
|
> 2
|
|
|
|
|
|
Which consensus engine to use? (default = clique)
|
|
|
1. Ethash - proof-of-work
|
|
|
2. Clique - proof-of-authority
|
|
|
> 2
|
|
|
|
|
|
How many seconds should blocks take? (default = 15)
|
|
|
>
|
|
|
|
|
|
Which accounts are allowed to seal? (mandatory at least one)
|
|
|
> 0x10c69b29d6f1bedc6fb97758f74a9f64eb2e7694
|
|
|
> 0x
|
|
|
|
|
|
Which accounts should be pre-funded? (advisable at least one)
|
|
|
> 0x10c69b29d6f1bedc6fb97758f74a9f64eb2e7694
|
|
|
> 0x
|
|
|
|
|
|
Specify your chain/network ID if you want an explicit one (default = random)
|
|
|
> 12345
|
|
|
INFO [10-11|11:41:26.635] Configured new genesis block
|
|
|
|
|
|
What would you like to do? (default = stats)
|
|
|
1. Show network stats
|
|
|
2. Manage existing genesis
|
|
|
3. Track new remote server
|
|
|
4. Deploy network components
|
|
|
> 2
|
|
|
|
|
|
1. Modify existing fork rules
|
|
|
2. Export genesis configuration
|
|
|
3. Remove genesis configuration
|
|
|
> 2
|
|
|
|
|
|
Which file to save the genesis into? (default = devnet.json)
|
|
|
> genesis.json
|
|
|
INFO [10-11|11:41:41.689] Exported existing genesis block
|
|
|
|
|
|
What would you like to do? (default = stats)
|
|
|
1. Show network stats
|
|
|
2. Manage existing genesis
|
|
|
3. Track new remote server
|
|
|
4. Deploy network components
|
|
|
> ^C
|
|
|
```
|
|
|
|
|
|
Finalizado este paso, el archivo `genesis.json` (si se eligió ese nombre), tiene la información necesaria para inicializar la red:
|
|
|
|
|
|
```
|
|
|
devnet$ geth --datadir network/node init genesis.json
|
|
|
```
|
|
|
|
|
|
## Lanzar el nodo
|
|
|
|
|
|
```
|
|
|
devnet$ geth --datadir network/node/ --syncmode 'full' --port 30303 --rpc --rpcaddr 'localhost' --rpcport 8545 --rpcapi 'personal,db,eth,net,web3,txpool,miner' --networkid 12345 --gasprice '1' --unlock '0x10c69b29d6f1bedc6fb97758f74a9f64eb2e7694' --password /dev/null --mine
|
|
|
```
|
|
|
|
|
|
## Conexión al nodo
|
|
|
|
|
|
### Mediante IPC
|
|
|
```
|
|
|
$ geth attach network/node/geth.ipc
|
|
|
Welcome to the Geth JavaScript console!
|
|
|
|
|
|
instance: Geth/v1.8.14-stable-316fc7ec/linux-amd64/go1.10.1
|
|
|
coinbase: 0xdf11900897ac4a842c1691dfd466b84adc7aa3d0
|
|
|
at block: 441 (Thu, 11 Oct 2018 12:06:52 -03)
|
|
|
datadir: /home/miguel/devnet/network/node
|
|
|
modules: admin:1.0 clique:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
|
|
|
|
|
|
>
|
|
|
```
|
|
|
|
|
|
### Mediante RPC
|
|
|
```
|
|
|
devnet$ geth attach http://localhost:8545
|
|
|
Welcome to the Geth JavaScript console!
|
|
|
|
|
|
instance: Geth/v1.8.14-stable-316fc7ec/linux-amd64/go1.10.1
|
|
|
coinbase: 0xdf11900897ac4a842c1691dfd466b84adc7aa3d0
|
|
|
at block: 448 (Thu, 11 Oct 2018 12:08:37 -03)
|
|
|
modules: eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
|
|
|
|
|
|
>
|
|
|
``` |
|
|
\ No newline at end of file |