EExcel 丞燕快速查詢2

EExcel 丞燕快速查詢2
EExcel 丞燕快速查詢2 https://sandk.ffbizs.com/

docker-compose ethereum geth private chain

Suggestion is use docker-machine for make docker machine is more easy. VirtualBox

windows Use HFS.exe for copy file to docker machine instance.




Directory < ethtest >
||=docker-compose.yml
||=< go-ether >
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp||=Dockerfile
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp||=start.sh
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp||=< genesis >
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp||=genesis.json


1、docker-compose.yml

import:

.keystore maybe no use, because run again docker-compose need to delete /go-ether/keystore
.entrypoint must have together Dockerfile ENTRYPOINT



version: '3.3'

services:
  go-ether:
    build:
      context: go-ether/
    volumes:
      #- ./go-ether/keystore:/root/.ethereum/devchain/keystore:rw
      - ./go-ether/genesis/genesis.json:/root/genesis/genesis.json:ro
      - /etc/localtime:/etc/localtime:ro
    entrypoint: /root/start.sh
    ports:
      - "8545:8545"
      - "30303:30303"
      - "30303:30303/udp"
    networks:
      - elk

networks:
  elk:
    driver: bridge




2、Dockerfile

import:

.COPY or ADD is ok
.Only start.sh is important, other line is for test and note
.Super important is start.sh file must end LF
https://sueboy.blogspot.com/2018/11/docker-compose-standardinitlinuxgo190.html




FROM ethereum/client-go:alltools-latest

RUN apk update &&\
    apk add git nodejs bash perl

#ADD ./genesis/genesis.json /root/genesis/genesis.json
#RUN geth init /root/genesis/genesis.json --datadir "~/.ethereum/devchain"

#RUN geth --dev --rpcapi "db,personal,eth,net,web3" --rpc --rpcaddr "0.0.0.0" --rpccorsdomain "*" --mine 
#geth --syncmode "light" --cache=2048
#./geth --datadir /root/.ethereum --password /root/geth.password --unlock "0" --port 30310 --rpc --rpcaddr "0.0.0.0" -rpcapi "eth,web3" --rpcport 8110 --networkid 4567890 --dev --lightkdf --nodiscover --maxpeers 0 --verbosity 6 --pprof --pprofport 6110 $@ 2> /tmp/geth.log

COPY start.sh /root/start.sh
RUN chmod +x /root/start.sh

ENTRYPOINT /root/start.sh







3、start.sh

import:

.last geth must have --minerthreads=1 , only --mini is can't mining. --mini login check geth.mining get true, but still no mining.




#!/bin/bash
set -e
datadir="~/.ethereum/devchain"
ip=$(echo `awk 'END{print $1}' /etc/hosts`)

echo "======== geth ========"
echo "======== init ========"
geth --datadir=$datadir init "/root/genesis/genesis.json"

sleep 2
echo "======== bootnode ========"
#bootnode -nodekeyhex 08f0e1dee5c1b4645f3331a566009e41a4514b6cd28656d63d0449ecf812812b &
bootnode --genkey=boot.key
bootnode --nodekey=boot.key -verbosity 4 &
#bootnode --nodekey=boot.key  -writeaddress > bootnodeid.txt

sleep 2
echo "======== account ========"
echo "password" > ~/.accountpassword
echo "df504d175ae63abf209bad9dda965310d99559620550e74521a6798a41215f46" > ~/.privatekey
geth account import --datadir=$datadir --password ~/.accountpassword  ~/.privatekey

sleep 2
echo "======== mine ========"
#bootnodeId="enode://76a8171707eca17647a47ca99ffd348927dfa60102792ea349a25d5192e61855be83b786e376276a306afcceea4ffd1c9c77e4370b417efc39f328a0d068004c@127.0.0.1:30301"
bootnodeId="enode://"$bootnodeid"@"$ip":30301"
address="8cc5a1a0802db41db826c2fcb72423744338dcb0"
echo "bootnodeID:"$bootnodeId
geth --datadir=$datadir --bootnodes $bootnodeId --networkid 45671 --rpcapi "db,personal,eth,net,web3" --rpc --rpcaddr "0.0.0.0" --rpccorsdomain "*"  --password ~/.accountpassword --etherbase $address --mine --minerthreads=1 2>geth.log





4、genesis.json



{
  "config": {
      "chainId": 45671,
      "homesteadBlock": 0,
      "eip150Block": 0,
      "eip150Hash":"0x0000000000000000000000000000000000000000000000000000000000000000",
      "eip155Block": 0,
      "eip158Block": 0,
      "byzantiumBlock": 0
  },
  "nonce": "0x0000000000000042",
  "timestamp": "0x00",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "extraData": "0x00",
  "gasLimit": "0x4c4b40",
  "difficulty": "0x0001",
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x0000000000000000000000000000000000000000",
  "alloc": {
  }
}





important:

1、genesis.json chainId & start.sh networkid must same.

2、datadir must have and same. If datadir different or no set, maybe can use same geth chain.

3、log must 2>geth.log 2>xxxooo.log xxxooo is log name.

4、--bootnodes maybe can have or not. Here is for demom, can try.



=====easy command=====

=====docker-machine=====
docker-machine --driver=virtualbox machine1 --virtualbox-memory 2048 --virtualbox-cpu-count 2 --engine-opt dns=8.8.8.8

docker-machien start machine1
docker-machien ssh machine1
docker-machien stop machine1

Move machine1 hdd to D: , stop first then use VirtualBox Media manager, don't change ini or config file.

=====docker-machine=====


=====copy edit txt file=====
On windows use HFS.exe put file into HFS.

rm -f docker-compose.yml && wget http://ip address/docker-compose.yml

rm start.sh -f && wget http://ip address/start.sh && rm -f Dockerfile && wget http://ip address/Dockerfile && rm genesis/genesis.json -f && wget -O genesis/genesis.json http://ip address/genesis.json

=====copy edit txt file=====



=====docker-compose=====
sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

.clear cache
chose 1:docker-compose rm -f && docker-compose pull && docker-compose up --build -d && docker-compose up
chose 2:docker-compose up --force-recreate

I use chose 1.
=====docker-compose=====



======login docker======
docker ps

xxxooo is docker container id, can use three or four word to login

docker exec -it xxxooo /bin/sh or /bin/bash Exit CTRL + P CTRL + Q
docker exec -it xxxooo geth attach ipc://root/.ethereum/devchain/geth.ipc

=====================


======login geth======
xxxooo is path, so "find / -name geth.ipc"

geth attach ipc:./xxxooo/geth.ipc


eth.accounts have account?
eth.mining can mining?
eth.blockNumber mining?
eth.getBalance(eth.accounts[0]) have ether coin?