如何在ubantu上启动go-ethereum客户端

环境准备

  • 安装git:sudo apt install git
  • 安装go:sudo apt install golang-go

go-ethereum(Geth)客户端下载和编译

clone源码:

1
https://gitee.com/guozhe001/go-ethereum.git

从源码构建geth

需要科学上网

1
2
cd go-ethereum
make geth

编译结果如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
env GO111MODULE=on go run build/ci.go install ./cmd/geth
>>> /usr/lib/go-1.13/bin/go build -ldflags -X main.gitCommit=54c0d573d75ab9baa239db3f071d6cb4d1ec6aad -X main.gitDate=20210325 -trimpath -v -o /home/guozhe/code/go-ethereum/build/bin/geth ./cmd/geth
go: downloading github.com/holiman/uint256 v1.1.1
go: downloading github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7
go: downloading golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
go: downloading github.com/edsrzf/mmap-go v1.0.0
go: downloading github.com/prometheus/tsdb v0.7.1
go: downloading github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
go: downloading github.com/golang/protobuf v1.4.3
go: downloading github.com/holiman/bloomfilter/v2 v2.0.3
go: downloading github.com/rs/cors v1.7.0
go: downloading github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef
go: extracting github.com/rs/cors v1.7.0
go: downloading github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c
go: extracting github.com/edsrzf/mmap-go v1.0.0
go: extracting github.com/holiman/uint256 v1.1.1
go: downloading github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356
go: extracting github.com/golang/protobuf v1.4.3
go: downloading github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3
go: extracting golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
go: downloading github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4
go: extracting github.com/prometheus/tsdb v0.7.1
go: downloading github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea
go: extracting github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7
go: downloading github.com/rjeczalik/notify v0.9.1
go: extracting github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef
go: downloading golang.org/x/text v0.3.3
go: extracting github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
go: downloading github.com/naoina/go-stringutil v0.1.0
go: downloading google.golang.org/protobuf v1.23.0
go: extracting github.com/holiman/bloomfilter/v2 v2.0.3
go: downloading github.com/dop251/goja v0.0.0-20200721192441-a695b0cdd498
go: extracting github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c
go: downloading github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954
go: extracting github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356
go: downloading github.com/pkg/errors v0.8.1
go: extracting github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3
go: downloading github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035
go: extracting github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4
go: downloading github.com/shirou/gopsutil v2.20.5+incompatible
go: extracting github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea
go: extracting github.com/rjeczalik/notify v0.9.1
go: downloading github.com/davecgh/go-spew v1.1.1
go: extracting github.com/naoina/go-stringutil v0.1.0
go: downloading github.com/huin/goupnp v1.0.1-0.20210310174557-0ca763054c88
go: extracting google.golang.org/protobuf v1.23.0
go: downloading github.com/fatih/color v1.7.0
go: extracting github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954
go: downloading github.com/graph-gophers/graphql-go v0.0.0-20201113091052-beb923fada29
go: extracting github.com/dop251/goja v0.0.0-20200721192441-a695b0cdd498
go: downloading github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458
go: extracting github.com/pkg/errors v0.8.1
go: extracting github.com/davecgh/go-spew v1.1.1
go: downloading github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e
go: extracting github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035
go: extracting github.com/huin/goupnp v1.0.1-0.20210310174557-0ca763054c88
go: downloading github.com/google/uuid v1.1.5
go: downloading github.com/go-sourcemap/sourcemap v2.1.2+incompatible
go: extracting github.com/shirou/gopsutil v2.20.5+incompatible
go: downloading github.com/go-stack/stack v1.8.0
go: extracting github.com/fatih/color v1.7.0
go: downloading golang.org/x/net v0.0.0-20200822124328-c89045814202
go: extracting github.com/graph-gophers/graphql-go v0.0.0-20201113091052-beb923fada29
go: extracting github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458
go: downloading gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6
go: extracting github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e
go: downloading github.com/mattn/go-runewidth v0.0.4
go: extracting github.com/go-sourcemap/sourcemap v2.1.2+incompatible
go: downloading github.com/opentracing/opentracing-go v1.1.0
go: extracting golang.org/x/text v0.3.3
go: extracting github.com/google/uuid v1.1.5
go: downloading github.com/gorilla/websocket v1.4.2
go: downloading github.com/VictoriaMetrics/fastcache v1.5.7
go: downloading github.com/dlclark/regexp2 v1.2.0
go: downloading github.com/influxdata/influxdb v1.8.3
go: extracting github.com/go-stack/stack v1.8.0
go: extracting golang.org/x/net v0.0.0-20200822124328-c89045814202
go: downloading golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
go: extracting gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6
go: extracting github.com/VictoriaMetrics/fastcache v1.5.7
go: downloading github.com/cespare/xxhash v1.1.0
go: extracting github.com/opentracing/opentracing-go v1.1.0
go: extracting github.com/gorilla/websocket v1.4.2
go: extracting github.com/dlclark/regexp2 v1.2.0
go: extracting github.com/mattn/go-runewidth v0.0.4
go: extracting golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
go: extracting github.com/cespare/xxhash v1.1.0
go: downloading github.com/cespare/xxhash/v2 v2.1.1
go: extracting github.com/cespare/xxhash/v2 v2.1.1
go: extracting github.com/influxdata/influxdb v1.8.3
go: finding gopkg.in/urfave/cli.v1 v1.20.0
go: finding github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7
go: finding github.com/dop251/goja v0.0.0-20200721192441-a695b0cdd498
go: finding github.com/VictoriaMetrics/fastcache v1.5.7
go: finding github.com/davecgh/go-spew v1.1.1
go: finding github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea
go: finding github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e
go: finding github.com/go-stack/stack v1.8.0
go: finding github.com/edsrzf/mmap-go v1.0.0
go: finding github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5
go: finding github.com/shirou/gopsutil v2.20.5+incompatible
go: finding github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416
go: finding github.com/mattn/go-colorable v0.1.0
go: finding github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035
go: finding github.com/holiman/bloomfilter/v2 v2.0.3
go: finding github.com/fatih/color v1.7.0
go: finding github.com/golang/protobuf v1.4.3
go: finding github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3
go: finding github.com/cespare/xxhash/v2 v2.1.1
go: finding github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954
go: finding github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c
go: finding github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
go: finding github.com/naoina/go-stringutil v0.1.0
go: finding github.com/dlclark/regexp2 v1.2.0
go: finding github.com/prometheus/tsdb v0.7.1
go: finding golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
go: finding github.com/google/uuid v1.1.5
go: finding github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356
go: finding github.com/rjeczalik/notify v0.9.1
go: finding github.com/mattn/go-runewidth v0.0.4
go: finding github.com/go-sourcemap/sourcemap v2.1.2+incompatible
go: finding github.com/pkg/errors v0.8.1
go: finding golang.org/x/text v0.3.3
go: finding github.com/holiman/uint256 v1.1.1
go: finding github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff
go: finding github.com/gorilla/websocket v1.4.2
go: finding github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4
go: finding github.com/rs/cors v1.7.0
go: finding github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef
go: finding google.golang.org/protobuf v1.23.0
go: finding github.com/huin/goupnp v1.0.1-0.20210310174557-0ca763054c88
go: finding github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458
go: finding github.com/influxdata/influxdb v1.8.3
go: finding github.com/graph-gophers/graphql-go v0.0.0-20201113091052-beb923fada29
go: finding golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
go: finding gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6
go: finding golang.org/x/net v0.0.0-20200822124328-c89045814202
go: finding golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
go: finding github.com/opentracing/opentracing-go v1.1.0
unicode
unicode/utf8
vendor/golang.org/x/crypto/cryptobyte/asn1
crypto/internal/subtle
math/bits
golang.org/x/sys/internal/unsafeheader
container/list
internal/nettrace
vendor/golang.org/x/crypto/internal/subtle
encoding
golang.org/x/net/html/atom
crypto/subtle
runtime/internal/sys
golang.org/x/text/encoding/internal/identifier
golang.org/x/text/internal/utf8internal
runtime/cgo
google.golang.org/protobuf/internal/flags
unicode/utf16
runtime/internal/atomic
container/ring
vendor/golang.org/x/crypto/curve25519
internal/race
internal/cpu
google.golang.org/protobuf/internal/fieldnum
sync/atomic
google.golang.org/protobuf/internal/genname
github.com/ethereum/go-ethereum/internal/web3ext
runtime/internal/math
internal/testlog
google.golang.org/protobuf/internal/set
internal/bytealg
math
runtime
internal/reflectlite
sync
google.golang.org/protobuf/internal/pragma
internal/singleflight
math/rand
errors
sort
internal/oserror
io
github.com/ethereum/go-ethereum/common/bitutil
github.com/hashicorp/golang-lru/simplelru
vendor/golang.org/x/net/dns/dnsmessage
strconv
syscall
container/heap
golang.org/x/text/internal/tag
bytes
hash
github.com/ethereum/go-ethereum/ethdb
crypto/internal/randutil
strings
text/tabwriter
github.com/go-sourcemap/sourcemap/internal/base64vlq
crypto/hmac
hash/fnv
hash/crc32
golang.org/x/crypto/pbkdf2
vendor/golang.org/x/crypto/hkdf
golang.org/x/crypto/hkdf
crypto/rc4
github.com/dop251/goja/token
crypto
reflect
golang.org/x/crypto/ripemd160
github.com/syndtr/goleveldb/leveldb/comparer
golang.org/x/text/transform
vendor/golang.org/x/text/transform
bufio
path
github.com/influxdata/influxdb/pkg/escape
encoding/base32
html
regexp/syntax
golang.org/x/text/runes
golang.org/x/text/encoding
golang.org/x/text/encoding/internal
golang.org/x/text/encoding/unicode
golang.org/x/text/encoding/charmap
golang.org/x/text/encoding/japanese
golang.org/x/text/encoding/traditionalchinese
golang.org/x/text/encoding/korean
golang.org/x/text/encoding/simplifiedchinese
github.com/ethereum/go-ethereum/common/fdlimit
internal/syscall/unix
github.com/mattn/go-isatty
time
regexp
context
github.com/naoina/toml/ast
github.com/ethereum/go-ethereum/common/mclock
internal/poll
github.com/ethereum/go-ethereum/common/prque
golang.org/x/sync/errgroup
os
internal/fmtsort
encoding/binary
crypto/md5
github.com/cespare/xxhash/v2
encoding/base64
crypto/sha1
crypto/sha256
golang.org/x/crypto/sha3
crypto/cipher
vendor/golang.org/x/crypto/poly1305
crypto/sha512
crypto/ed25519/internal/edwards25519
github.com/golang/snappy
vendor/golang.org/x/sys/cpu
golang.org/x/sys/unix
fmt
runtime/debug
path/filepath
github.com/mattn/go-runewidth
os/signal
google.golang.org/protobuf/internal/detrand
github.com/mattn/go-colorable
net
encoding/pem
crypto/aes
crypto/des
vendor/golang.org/x/crypto/internal/chacha20
golang.org/x/crypto/scrypt
io/ioutil
os/exec
vendor/golang.org/x/crypto/chacha20poly1305
golang.org/x/sys/cpu
database/sql/driver
encoding/json
encoding/hex
github.com/ethereum/go-ethereum/event
github.com/go-stack/stack
log
net/url
github.com/VictoriaMetrics/fastcache
github.com/syndtr/goleveldb/leveldb/util
math/big
github.com/syndtr/goleveldb/leveldb/storage
encoding/csv
github.com/pkg/errors
compress/flate
github.com/hashicorp/golang-lru
vendor/golang.org/x/net/http2/hpack
encoding/gob
mime
mime/quotedprintable
flag
vendor/golang.org/x/text/unicode/norm
net/http/internal
github.com/peterh/liner
vendor/golang.org/x/text/unicode/bidi
github.com/olekukonko/tablewriter
github.com/ethereum/go-ethereum/crypto/blake2b
encoding/xml
golang.org/x/net/html
golang.org/x/text/internal/language
github.com/syndtr/goleveldb/leveldb/cache
github.com/syndtr/goleveldb/leveldb/filter
github.com/status-im/keycard-go/derivationpath
golang.org/x/text/unicode/norm
google.golang.org/protobuf/internal/errors
go/token
google.golang.org/protobuf/internal/version
github.com/karalabe/usb
google.golang.org/protobuf/encoding/protowire
github.com/davecgh/go-spew/spew
github.com/syndtr/goleveldb/leveldb/errors
github.com/shirou/gopsutil/internal/common
google.golang.org/protobuf/reflect/protoreflect
github.com/tyler-smith/go-bip39/wordlists
github.com/syndtr/goleveldb/leveldb/iterator
github.com/syndtr/goleveldb/leveldb/journal
github.com/syndtr/goleveldb/leveldb/opt
compress/gzip
github.com/fjl/memsize
vendor/golang.org/x/text/secure/bidirule
text/template/parse
runtime/trace
os/user
github.com/ethereum/go-ethereum/console/prompt
golang.org/x/time/rate
runtime/pprof
github.com/ethereum/go-ethereum/eth/tracers/internal/tracers
golang.org/x/text/internal/language/compact
go/scanner
github.com/graph-gophers/graphql-go/errors
github.com/syndtr/goleveldb/leveldb/memdb
github.com/syndtr/goleveldb/leveldb/table
testing
text/scanner
github.com/graph-gophers/graphql-go/log
github.com/opentracing/opentracing-go/log
github.com/rjeczalik/notify
github.com/prometheus/tsdb/fileutil
github.com/edsrzf/mmap-go
go/ast
google.golang.org/protobuf/reflect/protoregistry
golang.org/x/text/language
google.golang.org/protobuf/internal/strs
google.golang.org/protobuf/internal/mapsort
google.golang.org/protobuf/internal/fieldsort
github.com/huin/goupnp/scpd
vendor/golang.org/x/net/idna
google.golang.org/protobuf/runtime/protoiface
google.golang.org/protobuf/internal/descfmt
github.com/deckarep/golang-set
github.com/shirou/gopsutil/cpu
google.golang.org/protobuf/internal/encoding/text
google.golang.org/protobuf/internal/descopts
github.com/graph-gophers/graphql-go/internal/common
github.com/influxdata/influxdb/models
github.com/dlclark/regexp2/syntax
github.com/syndtr/goleveldb/leveldb
github.com/dop251/goja/file
github.com/go-sourcemap/sourcemap
github.com/fatih/color
github.com/ethereum/go-ethereum/internal/jsre/deps
google.golang.org/protobuf/internal/encoding/messageset
github.com/naoina/go-stringutil
github.com/shirou/gopsutil/mem
text/template
github.com/ethereum/go-ethereum/common/hexutil
crypto/elliptic
encoding/asn1
crypto/rand
github.com/ethereum/go-ethereum/common/math
github.com/ethereum/go-ethereum/rlp
crypto/dsa
github.com/holiman/uint256
google.golang.org/protobuf/proto
github.com/graph-gophers/graphql-go/internal/schema
github.com/graph-gophers/graphql-go/internal/query
golang.org/x/text/encoding/htmlindex
github.com/dop251/goja/ast
golang.org/x/text/internal
go/parser
go/printer
google.golang.org/protobuf/internal/encoding/defval
golang.org/x/text/internal/colltab
github.com/holiman/bloomfilter/v2
crypto/ed25519
crypto/rsa
github.com/ethereum/go-ethereum/crypto/bn256/cloudflare
github.com/tyler-smith/go-bip39
golang.org/x/net/html/charset
github.com/graph-gophers/graphql-go/internal/exec/packer
github.com/graph-gophers/graphql-go/introspection
github.com/graph-gophers/graphql-go/internal/validation
github.com/dop251/goja/parser
golang.org/x/text/cases
golang.org/x/crypto/ed25519
crypto/x509/pkix
github.com/ethereum/go-ethereum/common
vendor/golang.org/x/crypto/cryptobyte
github.com/naoina/toml
gopkg.in/urfave/cli.v1
html/template
crypto/ecdsa
github.com/ethereum/go-ethereum/crypto/secp256k1
github.com/jedisct1/go-minisign
github.com/graph-gophers/graphql-go/internal/exec/resolvable
github.com/dlclark/regexp2
golang.org/x/text/collate
go/format
github.com/ethereum/go-ethereum/les/vflux
google.golang.org/protobuf/encoding/prototext
google.golang.org/protobuf/internal/filedesc
github.com/graph-gophers/graphql-go/internal/exec/selected
github.com/ethereum/go-ethereum/ethdb/memorydb
github.com/ethereum/go-ethereum/crypto/bls12381
github.com/ethereum/go-ethereum/crypto/bn256
google.golang.org/protobuf/internal/encoding/tag
google.golang.org/protobuf/internal/impl
log/syslog
vendor/golang.org/x/net/http/httpproxy
github.com/ethereum/go-ethereum/p2p/enr
github.com/jackpal/go-nat-pmp
github.com/ethereum/go-ethereum/p2p/netutil
net/textproto
github.com/gballet/go-libpcsclite
github.com/google/uuid
crypto/x509
gopkg.in/olebedev/go-duktape.v3
github.com/ethereum/go-ethereum/log
vendor/golang.org/x/net/http/httpguts
mime/multipart
github.com/ethereum/go-ethereum/signer/storage
github.com/ethereum/go-ethereum/les/flowcontrol
github.com/ethereum/go-ethereum/metrics
crypto/tls
github.com/ethereum/go-ethereum/ethdb/leveldb
google.golang.org/protobuf/internal/filetype
github.com/dop251/goja
google.golang.org/protobuf/runtime/protoimpl
github.com/golang/protobuf/proto
google.golang.org/protobuf/types/descriptorpb
net/http/httptrace
net/http
github.com/golang/protobuf/protoc-gen-go/descriptor
github.com/ethereum/go-ethereum/accounts/usbwallet/trezor
github.com/fjl/memsize/memsizeui
github.com/ethereum/go-ethereum/metrics/prometheus
github.com/rs/cors
expvar
github.com/influxdata/influxdb/client
net/http/pprof
github.com/huin/goupnp/soap
github.com/huin/goupnp/httpu
github.com/opentracing/opentracing-go
github.com/gorilla/websocket
github.com/opentracing/opentracing-go/ext
github.com/ethereum/go-ethereum/metrics/exp
github.com/graph-gophers/graphql-go/trace
github.com/huin/goupnp/ssdp
github.com/ethereum/go-ethereum/metrics/influxdb
github.com/graph-gophers/graphql-go/internal/exec
github.com/ethereum/go-ethereum/internal/debug
github.com/huin/goupnp
github.com/graph-gophers/graphql-go
github.com/ethereum/go-ethereum/rpc
github.com/huin/goupnp/dcps/internetgateway1
github.com/huin/goupnp/dcps/internetgateway2
github.com/ethereum/go-ethereum/internal/jsre
github.com/ethereum/go-ethereum/p2p/nat
github.com/ethereum/go-ethereum/crypto
github.com/ethereum/go-ethereum/crypto/ecies
github.com/ethereum/go-ethereum/p2p/enode
github.com/ethereum/go-ethereum/params
github.com/ethereum/go-ethereum/accounts/abi
github.com/ethereum/go-ethereum/p2p/rlpx
github.com/ethereum/go-ethereum/internal/flags
github.com/ethereum/go-ethereum/core/types
github.com/ethereum/go-ethereum/p2p/discover/v4wire
github.com/ethereum/go-ethereum/les/utils
github.com/ethereum/go-ethereum/p2p/dnsdisc
github.com/ethereum/go-ethereum/p2p/nodestate
github.com/ethereum/go-ethereum/p2p/discover/v5wire
github.com/ethereum/go-ethereum/les/vflux/client
github.com/ethereum/go-ethereum/les/vflux/server
github.com/ethereum/go-ethereum
github.com/ethereum/go-ethereum/eth/gasprice
github.com/ethereum/go-ethereum/core/forkid
github.com/ethereum/go-ethereum/core/bloombits
github.com/ethereum/go-ethereum/core/rawdb
github.com/ethereum/go-ethereum/core/vm
github.com/ethereum/go-ethereum/p2p/discover
github.com/ethereum/go-ethereum/accounts
github.com/ethereum/go-ethereum/ethclient
github.com/ethereum/go-ethereum/accounts/scwallet
github.com/ethereum/go-ethereum/accounts/keystore
github.com/ethereum/go-ethereum/accounts/usbwallet
github.com/ethereum/go-ethereum/p2p
github.com/ethereum/go-ethereum/console
github.com/ethereum/go-ethereum/trie
github.com/ethereum/go-ethereum/core/state/snapshot
github.com/ethereum/go-ethereum/core/state
github.com/ethereum/go-ethereum/consensus
github.com/ethereum/go-ethereum/consensus/misc
github.com/ethereum/go-ethereum/core/state/pruner
github.com/ethereum/go-ethereum/consensus/clique
github.com/ethereum/go-ethereum/consensus/ethash
github.com/ethereum/go-ethereum/core
github.com/ethereum/go-ethereum/eth/filters
github.com/ethereum/go-ethereum/eth/protocols/eth
github.com/ethereum/go-ethereum/eth/fetcher
github.com/ethereum/go-ethereum/light
github.com/ethereum/go-ethereum/eth/protocols/snap
github.com/ethereum/go-ethereum/eth/downloader
github.com/ethereum/go-ethereum/miner
github.com/ethereum/go-ethereum/internal/ethapi
github.com/ethereum/go-ethereum/signer/core
github.com/ethereum/go-ethereum/accounts/external
github.com/ethereum/go-ethereum/node
github.com/ethereum/go-ethereum/accounts/abi/bind
github.com/ethereum/go-ethereum/contracts/checkpointoracle/contract
github.com/ethereum/go-ethereum/accounts/abi/bind/backends
github.com/ethereum/go-ethereum/contracts/checkpointoracle
github.com/ethereum/go-ethereum/eth/ethconfig
github.com/ethereum/go-ethereum/graphql
github.com/ethereum/go-ethereum/les/checkpointoracle
github.com/ethereum/go-ethereum/eth
github.com/ethereum/go-ethereum/les
github.com/ethereum/go-ethereum/ethstats
github.com/ethereum/go-ethereum/eth/tracers
github.com/ethereum/go-ethereum/cmd/utils
github.com/ethereum/go-ethereum/cmd/geth
Done building.
Run "./build/bin/geth" to launch geth.

通过查看geth版本来确认geth是否已经安装正确:

1
2
3
4
5
6
7
8
9
10
$ ./build/bin/geth version
Geth
Version: 1.10.2-unstable
Git Commit: 54c0d573d75ab9baa239db3f071d6cb4d1ec6aad
Git Commit Date: 20210325
Architecture: amd64
Go Version: go1.13.8
Operating System: linux
GOPATH=
GOROOT=go

首次同步以太坊区块数据

查看go-ethereum的readme文档,默认是fast方式同步数据,直接运行geth console即可,因为数据比较大我单独挂载了一个磁盘,所以指定了数据存放的目录--datadir /data/ethereum/node

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
$ ./build/bin/geth console --datadir /data/ethereum/node/
INFO [03-27|16:25:39.409] Starting Geth on Ethereum mainnet...
INFO [03-27|16:25:39.409] Bumping default cache on mainnet provided=1024 updated=4096
INFO [03-27|16:25:39.411] Maximum peer count ETH=50 LES=0 total=50
INFO [03-27|16:25:39.411] Smartcard socket not found, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [03-27|16:25:39.412] Set global gas cap cap=25000000
INFO [03-27|16:25:39.412] Allocated trie memory caches clean=614.00MiB dirty=1024.00MiB
INFO [03-27|16:25:39.412] Allocated cache and file handles database=/data/ethereum/node/geth/chaindata cache=2.00GiB handles=524288
INFO [03-27|16:25:39.504] Opened ancient database database=/data/ethereum/node/geth/chaindata/ancient readonly=false
INFO [03-27|16:25:39.504] Writing default main-net genesis block
INFO [03-27|16:25:39.645] Persisted trie from memory database nodes=12356 size=1.78MiB time=48.710818ms gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [03-27|16:25:39.645] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: 7280000 Petersburg: 7280000 Istanbul: 9069000, Muir Glacier: 9200000, Berlin: 12244000, YOLO v3: <nil>, Engine: ethash}"
INFO [03-27|16:25:39.645] Disk storage enabled for ethash caches dir=/data/ethereum/node/geth/ethash count=3
INFO [03-27|16:25:39.645] Disk storage enabled for ethash DAGs dir=/home/guozhe/.ethash count=2
INFO [03-27|16:25:39.646] Initialising Ethereum protocol network=1 dbversion=<nil>
WARN [03-27|16:25:39.646] Upgrade blockchain database version from=<nil> to=8
INFO [03-27|16:25:39.646] Loaded most recent local header number=0 hash="d4e567…cb8fa3" td=17179869184 age=51y11mo3w
INFO [03-27|16:25:39.646] Loaded most recent local full block number=0 hash="d4e567…cb8fa3" td=17179869184 age=51y11mo3w
INFO [03-27|16:25:39.646] Loaded most recent local fast block number=0 hash="d4e567…cb8fa3" td=17179869184 age=51y11mo3w
WARN [03-27|16:25:39.646] Failed to load snapshot, regenerating err="missing or corrupted snapshot"
INFO [03-27|16:25:39.646] Rebuilding state snapshot
INFO [03-27|16:25:39.646] Deleted state snapshot leftovers kind=accounts wiped=0 elapsed="47.755µs"
INFO [03-27|16:25:39.647] Deleted state snapshot leftovers kind=storage wiped=0 elapsed="17.809µs"
INFO [03-27|16:25:39.647] Compacting snapshot account area
INFO [03-27|16:25:39.647] Regenerated local transaction journal transactions=0 accounts=0
INFO [03-27|16:25:39.650] Wiper running, state snapshotting paused accounts=0 slots=0 storage=0.00B elapsed="361.935µs"
INFO [03-27|16:25:39.676] Allocated fast sync bloom size=2.00GiB
WARN [03-27|16:25:39.677] Error reading unclean shutdown markers error="leveldb: not found"
INFO [03-27|16:25:39.677] Starting peer-to-peer node instance=Geth/v1.10.2-unstable-54c0d573-20210325/linux-amd64/go1.13.8
INFO [03-27|16:25:39.741] Initialized state bloom items=12356 errorrate=0.000 elapsed=64.036ms
INFO [03-27|16:25:39.817] New local node record seq=1 id=0d81eb9b177ba542 ip=127.0.0.1 udp=30303 tcp=30303
INFO [03-27|16:25:39.817] Started P2P networking self=enode://dbb9a7d3a1ca59a200c1fa920b2cc467c342182b0f818c491028da1c564391f2cb91f0ce88bb7826264e609aa407dd8544224c0dd3d1a3f6bc449fd063dbdde7@127.0.0.1:30303
INFO [03-27|16:25:39.818] IPC endpoint opened url=/data/ethereum/node/geth.ipc
WARN [03-27|16:25:39.858] Served eth_coinbase reqid=3 t="12.338µs" err="etherbase must be explicitly specified"
Welcome to the Geth JavaScript console!

instance: Geth/v1.10.2-unstable-54c0d573-20210325/linux-amd64/go1.13.8
at block: 0 (Thu Jan 01 1970 08:00:00 GMT+0800 (CST))
datadir: /data/ethereum/node
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

To exit, press ctrl-d
> INFO [03-27|16:25:39.924] Compacting snapshot storage area
INFO [03-27|16:25:39.924] Compacted snapshot area in database elapsed=277.624ms
INFO [03-27|16:25:39.924] Resuming state snapshot generation root="d7f897…0f0544" accounts=0 slots=0 storage=0.00B elapsed="9.119µs"
INFO [03-27|16:25:39.996] Generated state snapshot accounts=8893 slots=0 storage=409.64KiB elapsed=71.524ms
INFO [03-27|16:25:46.015] New local node record seq=2 id=0d81eb9b177ba542 ip=115.171.250.78 udp=52360 tcp=30303
INFO [03-27|16:25:50.847] Looking for peers peercount=0 tried=8 static=0
INFO [03-27|16:25:56.124] Block synchronisation started
INFO [03-27|16:26:01.068] Looking for peers peercount=0 tried=4 static=0
WARN [03-27|16:26:05.414] Dropping unsynced node during sync id=46e8efbdd811cf2e conn=dyndial addr=207.148.3.150:30303 type=Geth/v1.9.25-stable-...
INFO [03-27|16:26:11.068] Looking for peers peercount=2 tried=15 static=0
WARN [03-27|16:26:12.135] Dropping unsynced node during sync id=53455744030e83cc conn=dyndial addr=108.61.176.254:30303 type=Geth/v1.9.25-stable-...

查看/data/ethereum/node目录

1
2
3
4
5
6
$ ll
总用量 1
drwxrwxrwx 1 root root 472 3月 27 16:28 geth/
srwxrwxrwx 1 root root 1 3月 27 16:25 geth.ipc=
drwxrwxrwx 1 root root 0 3月 27 16:25 keystore/

调用geth的json-rpc接口

1
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}' http://localhost:8545