geth 1.9.1アップデート


infura.ioが課金を初めて阿鼻叫喚のみなさまこんにちわ。
ほぼ電気代ぐらいの金額ってのは救いですね。

7/24に1.9.1がリリースされたのでアップデートメモです。
https://github.com/ethereum/go-ethereum/releases

今回は1.9.0から1.9.1にアップデートしませう。

TL;DR

すんなりアップデートできてしまったので、今回追加されたeth_getHeaderByNumber and eth_getHeaderByHashを試しています。

[ec2-user@ip-10-20-0-250 ~]$ go version
go version go1.9.4 linux/amd64

DLします

[ec2-user@ip-10-20-0-250 ~]$ wget https://github.com/ethereum/go-ethereum/archive/v1.9.1.tar.gz
--2019-07-30 01:49:14--  https://github.com/ethereum/go-ethereum/archive/v1.9.1.tar.gz
Resolving github.com (github.com)... 52.69.186.44
Connecting to github.com (github.com)|52.69.186.44|:443... connected.
HTTP request sent, awaiting response... 302 Found

~snip

[ec2-user@ip-10-20-0-250 ~]$ tar zxfv v1.9.1.tar.gz

~snip

ビルドします

[ec2-user@ip-10-20-0-250 ~]$ cd go-ethereum-1.9.1/
[ec2-user@ip-10-20-0-250 go-ethereum-1.9.1]$ ll
total 160
drwxrwxr-x  7 ec2-user ec2-user   239 Jul 24 06:41 accounts
-rw-rw-r--  1 ec2-user ec2-user  1097 Jul 24 06:41 appveyor.yml
-rw-rw-r--  1 ec2-user ec2-user 13696 Jul 24 06:41 AUTHORS
drwxrwxr-x  3 ec2-user ec2-user  4096 Jul 24 06:41 build
-rw-rw-r--  1 ec2-user ec2-user  1544 Jul 24 06:41 circle.yml
drwxrwxr-x 16 ec2-user ec2-user   207 Jul 24 06:41 cmd


~snip

[ec2-user@ip-10-20-0-250 go-ethereum-1.9.1]$ make
build/env.sh go run build/ci.go install ./cmd/geth


~snip

github.com/ethereum/go-ethereum/vendor/github.com/fatih/color
github.com/ethereum/go-ethereum/vendor/gopkg.in/sourcemap.v1/base64vlq
github.com/ethereum/go-ethereum/vendor/gopkg.in/sourcemap.v1
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/file
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/token
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/ast
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/dbg
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/parser
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/registry
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto
github.com/ethereum/go-ethereum/internal/jsre
github.com/ethereum/go-ethereum/internal/web3ext
github.com/ethereum/go-ethereum/vendor/github.com/peterh/liner
github.com/ethereum/go-ethereum/console
github.com/ethereum/go-ethereum/ethclient
github.com/ethereum/go-ethereum/vendor/github.com/naoina/go-stringutil
github.com/ethereum/go-ethereum/vendor/github.com/naoina/toml/ast
github.com/ethereum/go-ethereum/vendor/github.com/naoina/toml
github.com/ethereum/go-ethereum/eth/tracers
github.com/ethereum/go-ethereum/eth
github.com/ethereum/go-ethereum/les
github.com/ethereum/go-ethereum/ethstats
github.com/ethereum/go-ethereum/cmd/utils
github.com/ethereum/go-ethereum/cmd/geth
Done building.
Run "/home/ec2-user/go-ethereum-1.9.1/build/bin/geth" to launch geth.

1.9.0を落として1.9.1を上げます。

1.9.0のほう
INFO [07-30|01:55:42.039] Imported new chain segment               blocks=1  txs=187  mgas=7.935   elapsed=347.816ms mgasps=22.814  number=8249119 hash=8f3ac5…21f855 dirty=990.99MiB
^CINFO [07-30|01:55:54.476] Got interrupt, shutting down...
INFO [07-30|01:55:54.477] WebSocket endpoint closed                url=ws://0.0.0.0:8546
INFO [07-30|01:55:54.478] HTTP endpoint closed                     url=http://0.0.0.0:8545
INFO [07-30|01:55:54.478] IPC endpoint closed                      url=/extend-data/geth/geth.ipc
INFO [07-30|01:55:54.478] Writing cached state to disk             block=8249119 hash=8f3ac5…21f855 root=ebfbb2…41cfd9
^[[AINFO [07-30|01:56:01.148] Deep froze chain segment                 blocks=5  elapsed=24.276ms  number=8159118 hash=be98fc…19c8ab
INFO [07-30|01:57:08.645] Persisted trie from memory database      nodes=2746131 size=639.77MiB  time=1m22.408657013s gcnodes=10941972 gcsize=4.26GiB gctime=2m22.214644662s livenodes=205060 livesize=60.01MiB
INFO [07-30|01:57:08.645] Writing cached state to disk             block=8249118 hash=9480b1…29660c root=f8d3c2…5ca051
INFO [07-30|01:57:08.722] Persisted trie from memory database      nodes=2517    size=1006.55KiB time=77.215342ms     gcnodes=0        gcsize=0.00B   gctime=0s              livenodes=202543 livesize=59.03MiB
INFO [07-30|01:57:08.722] Writing cached state to disk             block=8248992 hash=36e472…592f44 root=11ef4a…bcf7ae
INFO [07-30|01:57:10.185] Persisted trie from memory database      nodes=63054   size=23.68MiB   time=1.463025926s    gcnodes=0        gcsize=0.00B   gctime=0s              livenodes=139489 livesize=35.35MiB
ERROR[07-30|01:57:11.213] Dangling trie nodes after full cleanup
INFO [07-30|01:57:11.213] Blockchain manager stopped
INFO [07-30|01:57:11.213] Stopping Ethereum protocol
INFO [07-30|01:57:12.765] Ethereum protocol stopped
INFO [07-30|01:57:12.765] Transaction pool stopped

1.9.1のほう
[ec2-user@ip-10-20-0-250 go-ethereum-1.9.1]$  ./build/bin/geth --datadir=/extend-data/geth --syncmode=fast --ws --rpc
INFO [07-30|01:57:45.770] Bumping default cache on mainnet         provided=1024 updated=4096
INFO [07-30|01:57:45.773] Maximum peer count                       ETH=50 LES=0 total=50
INFO [07-30|01:57:45.773] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
ERROR[07-30|01:57:45.774] Failed to enumerate USB devices          hub=ledger vendor=11415 failcount=1 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[07-30|01:57:45.774] Failed to enumerate USB devices          hub=trezor vendor=21324 failcount=1 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[07-30|01:57:45.774] Failed to enumerate USB devices          hub=trezor vendor=4617  failcount=1 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[07-30|01:57:45.774] Failed to enumerate USB devices          hub=ledger vendor=11415 failcount=2 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[07-30|01:57:45.774] Failed to enumerate USB devices          hub=trezor vendor=21324 failcount=2 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[07-30|01:57:45.774] Failed to enumerate USB devices          hub=trezor vendor=4617  failcount=2 err="failed to initialize libusb: libusb: unknown error [code -99]"
INFO [07-30|01:57:45.776] Starting peer-to-peer node               instance=Geth/v1.9.1-stable/linux-amd64/go1.9.4
INFO [07-30|01:57:45.776] Allocated trie memory caches             clean=1024.00MiB dirty=1024.00MiB
INFO [07-30|01:57:45.777] Allocated cache and file handles         database=/extend-data/geth/geth/chaindata cache=2.00GiB handles=2048
ERROR[07-30|01:57:46.776] Failed to enumerate USB devices          hub=trezor vendor=4617  failcount=3 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[07-30|01:57:46.777] Failed to enumerate USB devices          hub=ledger vendor=11415 failcount=3 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[07-30|01:57:46.777] Failed to enumerate USB devices          hub=trezor vendor=21324 failcount=3 err="failed to initialize libusb: libusb: unknown error [code -99]"
INFO [07-30|01:58:02.795] Opened ancient database                  database=/extend-data/geth/geth/chaindata/ancient
INFO [07-30|01:58:02.807] Initialised chain configuration          config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: 7280000  Petersburg: 7280000 Engine: ethash}"
INFO [07-30|01:58:02.807] Disk storage enabled for ethash caches   dir=/extend-data/geth/geth/ethash count=3
INFO [07-30|01:58:02.807] Disk storage enabled for ethash DAGs     dir=/home/ec2-user/.ethash        count=2
INFO [07-30|01:58:02.807] Initialising Ethereum protocol           versions=[63] network=1 dbversion=7
INFO [07-30|01:58:02.912] Loaded most recent local header          number=8249119 hash=8f3ac5…21f855 td=11233427599166047214883 age=2m24s
INFO [07-30|01:58:02.912] Loaded most recent local full block      number=8249119 hash=8f3ac5…21f855 td=11233427599166047214883 age=2m24s
INFO [07-30|01:58:02.913] Loaded most recent local fast block      number=8249119 hash=8f3ac5…21f855 td=11233427599166047214883 age=2m24s
INFO [07-30|01:58:02.914] Loaded local transaction journal         transactions=0 dropped=0

すんなり起動してしまいました。

今回追加されたeth_getHeaderByNumber and eth_getHeaderByHashを試してみましょうか。lightクライアントモードでヘッダーをピアに取りに行っていたのが無駄じゃないかということで追加されたものみたいです。

attachしてeth.getHeaderByHashで適当なブロックヘッダーを見てみます。

> [ec2-user@ip-10-20-0-250 go-ethereum-1.9.1]$ ./build/bin/geth attach --datadir=/extend-data/geth
INFO [07-30|02:06:28.441] Bumping default cache on mainnet         provided=1024 updated=4096
Welcome to the Geth JavaScript console!

instance: Geth/v1.9.1-stable/linux-amd64/go1.9.4
at block: 8249168 (Tue, 30 Jul 2019 02:05:56 UTC)
 datadir: /extend-data/geth
 modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> eth.getHeaderByHash('0xd6a8bdf1fbd76b11a536ff8c19dda6f704a3db665c8a9c2b1f32434c26f7b349')
{
  difficulty: "0x7e5b992fc0167",
  extraData: "0x7a68697a68755f3030303033",
  gasLimit: "0x7a1200",
  gasUsed: "0x36c501",
  hash: "0xd6a8bdf1fbd76b11a536ff8c19dda6f704a3db665c8a9c2b1f32434c26f7b349",
  logsBloom: "0x008127d60400000808000406250100818880400010800000860480000204080000000184401008000040c002110401c000411010300003010020110062b00080c801004024120800180014088003010100002400120822000000a0024900121010042340424307404001600101205941080c1204000004008005413120e00401020011204050020080010414888400900400cc600900430028a1000ac810012802020080040220019090928004019800104090040d004800000000009d100561040041f2000080400044800805226001a002008590300004000002006040310000104a000020000710000020000030043040c000801008098851b01200820010",
  miner: "0x04668ec2f57cc15c381b461b9fedab5d451c8f7f",
  mixHash: "0x702839c956b0e0cd125a9d4ee77847f64a3bf1090de8f15d83d30f7ee62e0f18",
  nonce: "0x7294be7401448aaa",
  number: "0x7ddf37",
  parentHash: "0x681d97ada030bee469efb871f71738ba21c2b89b09e23ae555cd30b264f5378d",
  receiptsRoot: "0x05b4ca8419c12ff1c816cf7bd2132bc9408642a01f3f1cbb3a456e235a48bc0a",
  sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  size: "0x235",
  stateRoot: "0xdbcdc97ab0adc71a9ee7ddf24c7ddb892bb4ede4135cf22e86d29cde50840ca6",
  timestamp: "0x5d3fa4a4",
  totalDifficulty: "0x260f7dd37268146a7c8",
  transactionsRoot: "0xe53c5793fb66ff2b8cc3b2f738eaab5edc1851163f209d9cacb8c6d29cf5a233"
}

getHeaderByNumberはhexでよこせってことなので0xで。

> eth.getHeaderByNumber('0x7ddf37')
{
  difficulty: "0x7e5b992fc0167",
  extraData: "0x7a68697a68755f3030303033",
  gasLimit: "0x7a1200",
  gasUsed: "0x36c501",
  hash: "0xd6a8bdf1fbd76b11a536ff8c19dda6f704a3db665c8a9c2b1f32434c26f7b349",
  logsBloom: "0x008127d60400000808000406250100818880400010800000860480000204080000000184401008000040c002110401c000411010300003010020110062b00080c801004024120800180014088003010100002400120822000000a0024900121010042340424307404001600101205941080c1204000004008005413120e00401020011204050020080010414888400900400cc600900430028a1000ac810012802020080040220019090928004019800104090040d004800000000009d100561040041f2000080400044800805226001a002008590300004000002006040310000104a000020000710000020000030043040c000801008098851b01200820010",
  miner: "0x04668ec2f57cc15c381b461b9fedab5d451c8f7f",
  mixHash: "0x702839c956b0e0cd125a9d4ee77847f64a3bf1090de8f15d83d30f7ee62e0f18",
  nonce: "0x7294be7401448aaa",
  number: "0x7ddf37",
  parentHash: "0x681d97ada030bee469efb871f71738ba21c2b89b09e23ae555cd30b264f5378d",
  receiptsRoot: "0x05b4ca8419c12ff1c816cf7bd2132bc9408642a01f3f1cbb3a456e235a48bc0a",
  sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  size: "0x235",
  stateRoot: "0xdbcdc97ab0adc71a9ee7ddf24c7ddb892bb4ede4135cf22e86d29cde50840ca6",
  timestamp: "0x5d3fa4a4",
  totalDifficulty: "0x260f7dd37268146a7c8",
  transactionsRoot: "0xe53c5793fb66ff2b8cc3b2f738eaab5edc1851163f209d9cacb8c6d29cf5a233"
}