ethereum-编译geth

2023-10-23 14:22:20 浏览数 (3)

前言

geth 是将计算机变成一个以太坊节点,连接到以太坊网络的客户端。

对于geth的几个问题:

  • 有了 geth 之后能做什么?
  • 该怎么用?
  • 用了之后能了解到什么?

能做几件事:

  1. 成为一个以太坊节点,可以是:全节点、矿工节点、归档节点
  2. 可以当在一个gRPC 的查询工具来用
  3. 生成账户等操作

一句话总结:geth就代表运行在你电脑上的以太坊程序。

环境准备

这里说明只基于对开发环境的基础配置,官方要求的配置更高

最小硬件要求

  • CPU 2 cores
  • 4GB RAM
  • 1TB
  • 8 MBit/sec

go安装

  • go1.16.x 安装
  • gcc 编译geth

注意需要修改一下go代理:

代码语言:javascript复制
go env -w GOPROXY=https://goproxy.cn

安装gcc

代码语言:javascript复制
yum install gcc

编译

下载源码之后,看一下README.md,使用make geth就行编译,编译一下

代码语言:javascript复制
git clone https://github.com/ethereum/go-ethereum.git
cd  go-ethereum
# 查看所有分支 git brarnch -a
git checkout release/1.9
make geth
make all

开始编译后输出:

代码语言:javascript复制
github.com/ethereum/go-ethereum/eth/filters
github.com/ethereum/go-ethereum/light
github.com/ethereum/go-ethereum/eth/protocols/eth
github.com/ethereum/go-ethereum/accounts/abi/bind/backends
github.com/ethereum/go-ethereum/internal/ethapi
github.com/ethereum/go-ethereum/eth/fetcher
github.com/ethereum/go-ethereum/eth/protocols/snap
github.com/ethereum/go-ethereum/eth/tracers
github.com/ethereum/go-ethereum/graphql
github.com/ethereum/go-ethereum/les/downloader
github.com/ethereum/go-ethereum/eth/downloader
github.com/ethereum/go-ethereum/eth/tracers/js
github.com/ethereum/go-ethereum/eth/tracers/native
github.com/ethereum/go-ethereum/miner
github.com/ethereum/go-ethereum/eth/ethconfig
github.com/ethereum/go-ethereum/eth
github.com/ethereum/go-ethereum/les
github.com/ethereum/go-ethereum/eth/catalyst
github.com/ethereum/go-ethereum/les/catalyst
github.com/ethereum/go-ethereum/ethstats
github.com/ethereum/go-ethereum/cmd/utils
github.com/ethereum/go-ethereum/cmd/geth
Done building.
Run "./build/bin/geth" to launch geth.

可以看到geth被编译到了: ./build/bin/geth,这个路径。

执行下看看编译是否成功:

代码语言:javascript复制
./build/bin/geth --help

成功

代码语言:javascript复制
    --txpool.globalqueue value     (default: 1024)
          Maximum number of non-executable transaction slots for all accounts
   
    --txpool.globalslots value     (default: 5120)
          Maximum number of executable transaction slots for all accounts
   
    --txpool.journal value         (default: "transactions.rlp")
          Disk journal for local transaction to survive node restarts
   
    --txpool.lifetime value        (default: 3h0m0s)
          Maximum amount of time non-executable transaction are queued
   
    --txpool.locals value         
          Comma separated accounts to treat as locals (no flush, priority inclusion)
   
    --txpool.nolocals              (default: false)
          Disables price exemptions for locally submitted transactions
   
    --txpool.pricebump value       (default: 10)
          Price bump percentage to replace an already existing transaction
   
    --txpool.pricelimit value      (default: 1)
          Minimum gas price limit to enforce for acceptance into the pool
   
    --txpool.rejournal value       (default: 1h0m0s)
          Time interval to regenerate the local transaction journal
   
   VIRTUAL MACHINE
   
    --vmdebug                      (default: false)
          Record information useful for VM and contract debugging
   

COPYRIGHT:
   Copyright 2013-2022 The go-ethereum Authors

总结

如果是 windows 机器,建议装个虚拟机操作,在Linux环境下使用起来更顺手一些。

参考文档

https://github.com/ethereum/go-ethereum https://geth.ethereum.org/docs/getting-started

0 人点赞