使用 Kurtosis 搭建本地私链
前言:
随着以太坊网络从工作量证明(PoW)转向权益证明(PoS),Geth 不再支持通过 Ethash 或 Clique 共识机制来封装区块。现在,Geth 只能在 PoS 模式下与共识客户端(如 Prysm、Lighthouse、Teku 等)配合使用。
目录:
文章目录
首先安装 Docker
可以查看作者之前的文章服务器搭建开发环境中有 docker
如何在 Centos
系统上的安装教程。
按照教程安装完成后可以使用以下命令启动并查看是否安装成功。
# 启动 docker
systemctl start docker
# 查看 docker 状态
systemctl status docker
docker 其他命令
docker stop $(docker ps -aq) # 停止所有容器
docker rm $(docker ps -aq) # 删除所有容器
docker rmi $(docker images -q) # 删除所有镜像
docker network prune # 删除所有未使用的网络
docker volume prune # 删除所有未使用的卷
安装 Kurtosis CLI
使用以下命令安装 Kurtosis CLI。(看系统选择命令)
-
brew (MacOS)苹果系统
brew install kurtosis-tech/tap/kurtosis-cli
-
apt (Ubuntu)
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list sudo apt update sudo apt install kurtosis-cli
-
yum (RHEL)
echo '[kurtosis] name=Kurtosis baseurl=https://yum.fury.io/kurtosis-tech/ enabled=1 gpgcheck=0' | sudo tee /etc/yum.repos.d/kurtosis.repo sudo yum install kurtosis-cli
安装成功后,可以通过以下命令判断是否安装成功。成功显示出版本号即成功。
kurtosis version
kurtosis 其他命令
kurtosis engine status # 显示当前 Kurtosis 引擎的状态信息,包括版本、运行状态等。
kurtosis engine logs #查看 Kurtosis 引擎的日志,以帮助诊断和调试问题
kurtosis engine stop #停止当前正在运行的 Kurtosis 引擎。这会停止所有关联的 enclave。
kurtosis engine clean #清理所有 enclave 和关联的资源,同时停止 Kurtosis 引擎。这对于完全重置环境非常有用。
kurtosis engine start #启动 Kurtosis 引擎。如果引擎之前已经停止,可以用这个命令重新启动它。
kurtosis engine restart #重启 Kurtosis 引擎,相当于先停止再启动。
kurtosis engine set-log-level debug #设置 Kurtosis 引擎的日志级别,可以在不同级别之间切换以获得不同的日志详细度(如 debug、info、warn、error)。
kurtosis run <package> #可以通过 Github URL 或 git 存储库的本地路径启动任何包。
kurtosis enclave rm -f <enclave-name> #清理对应的enclave-name的资源
kurtosis clean -a #清理所有资源
kurtosis service shell my-testnet $SERVICE_NAME # shell 访问权限
kurtosis service logs my-testnet $SERVICE_NAME # 访问服务的日志
使用默认配置启动单节点私链
使用以下命令启动单节点私链。
kurtosis run --enclave my-testnet github.com/ethpandaops/ethereum-package
这命令中的 enclave
是一个隔离的虚拟环境,my-testnet
则是起的名字。运行这个命令后,Kurtosis 将在 my-testnet
这个 enclave
中启动一个独立的以太坊网络,包括执行层(Geth)和共识层(例如 Teku、Prysm 等)。
出现以下输出则是启动成功。
注意:输出数据不可能完全一样,格式类似即成功。
Reading genesis validators root
Command returned with exit code '0' and the following output: 0xd61ea484febacfae5298d52a2b581f3e305a51f3112a9241b968dccf019f7b11
Reading prague time from genesis
Command returned with exit code '0' and the following output: 40123938434
Adding service with name 'el-1-geth-lighthouse' and image 'ethereum/client-go:latest'
Service 'el-1-geth-lighthouse' added with service UUID '1820eff8ef774347aac20d159289b94e'
Waiting for at most '15m0s' for service 'el-1-geth-lighthouse' to reach a certain state
Wait took 1 tries (12.05992ms in total). Assertion passed with following:
Request had response code '200' and body "{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"id\":\"fe4255e481f0b2dc98804e0d0957ce4e94e0b2b4c041a456d5787f647dfe1a39\",\"name\":\"Geth/v1.14.9-unstable-710c3f32/linux-amd64/go1.22.6\",\"enode\":\"enode://17ff80eba12e11fe4d3339303e7d0d5eabf2ec1ad5248a06b136b6602f5b93891d681212e3ea157f7e52a7284c1b2b8d532c18298b94cf3598826f760c2fd8df@172.16.0.10:30303\",\"enr\":\"enr:-Ki4QHFsARFD4V31ZlT5bYsY4P6ovJlmAgqRHNdQTQsr-GAcbE32AWI4V_l7EdMEKZg4OO25K3Bi8EWE_u6T8nUgaOaGAZFivExyg2V0aMzLhJpTGo2FCVeStoKCaWSCdjSCaXCErBAAColzZWNwMjU2azGhAxf_gOuhLhH-TTM5MD59DV6r8uwa1SSKBrE2tmAvW5OJhHNuYXDAg3RjcIJ2X4N1ZHCCdl8\",\"ip\":\"172.16.0.10\",\"ports\":{\"discovery\":30303,\"listener\":30303},\"listenAddr\":\"[::]:30303\",\"protocols\":{\"eth\":{\"network\":3151908,\"difficulty\":1,\"genesis\":\"0xf8edafd86de5d602ee1527c7e644e9785fbfa9290a56ffe44c0b44ceed8ce16b\",\"config\":{\"chainId\":3151908,\"homesteadBlock\":0,\"eip150Block\":0,\"eip155Block\":0,\"eip158Block\":0,\"byzantiumBlock\":0,\"constantinopleBlock\":0,\"petersburgBlock\":0,\"istanbulBlock\":0,\"berlinBlock\":0,\"londonBlock\":0,\"mergeNetsplitBlock\":0,\"shanghaiTime\":0,\"cancunTime\":0,\"pragueTime\":40123938434,\"terminalTotalDifficulty\":0,\"terminalTotalDifficultyPassed\":true},\"head\":\"0xf8edafd86de5d602ee1527c7e644e9785fbfa9290a56ffe44c0b44ceed8ce16b\"},\"snap\":{}}}}\n", with extracted fields:
'extract.enr': "enr:-Ki4QHFsARFD4V31ZlT5bYsY4P6ovJlmAgqRHNdQTQsr-GAcbE32AWI4V_l7EdMEKZg4OO25K3Bi8EWE_u6T8nUgaOaGAZFivExyg2V0aMzLhJpTGo2FCVeStoKCaWSCdjSCaXCErBAAColzZWNwMjU2azGhAxf_gOuhLhH-TTM5MD59DV6r8uwa1SSKBrE2tmAvW5OJhHNuYXDAg3RjcIJ2X4N1ZHCCdl8"
'extract.enode': "enode://17ff80eba12e11fe4d3339303e7d0d5eabf2ec1ad5248a06b136b6602f5b93891d681212e3ea157f7e52a7284c1b2b8d532c18298b94cf3598826f760c2fd8df@172.16.0.10:30303"
Printing a message
Successfully added 1 EL participants
Printing a message
Launching CL network
Adding service with name 'cl-1-lighthouse-geth' and image 'ethpandaops/lighthouse:stable'
Service 'cl-1-lighthouse-geth' added with service UUID '3c8393ddc3694ae5af8154066dbbea16'
Running 'GET' request on service 'cl-1-lighthouse-geth'
Request had response code '200' and body "{\"data\":{\"peer_id\":\"16Uiu2HAkzXDGenowpuF1qug5uuHJ8fnwz5x2EQeWVQtp5isVA8CB\",\"enr\":\"enr:-MS4QFAWdthn3BhmQC7euQvNr_2AtWqzlzd40q2n7yGtBQJkYEvDZVrVhwd4g9BlQKPfrlX_4W6V-MjrWDy-Qf5iu2sBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpBPtyXhYAAAOADh9QUAAAAAgmlkgnY0gmlwhKwQAAuEcXVpY4IjKYlzZWNwMjU2azGhAku1uBo7WOJ21Oe4jVH76wSUCrlffpBcXjjLhY-jDYQsiHN5bmNuZXRzAIN0Y3CCIyiDdWRwgiMo\",\"p2p_addresses\":[\"/ip4/172.16.0.11/tcp/9000/p2p/16Uiu2HAkzXDGenowpuF1qug5uuHJ8fnwz5x2EQeWVQtp5isVA8CB\"],\"discovery_addresses\":[\"/ip4/172.16.0.11/udp/9000/p2p/16Uiu2HAkzXDGenowpuF1qug5uuHJ8fnwz5x2EQeWVQtp5isVA8CB\"],\"metadata\":{\"seq_number\":\"0\",\"attnets\":\"0x0000000000000000\",\"syncnets\":\"0x00\"}}}", with extracted fields:
'extract.multiaddr': "/ip4/172.16.0.11/tcp/9000/p2p/16Uiu2HAkzXDGenowpuF1qug5uuHJ8fnwz5x2EQeWVQtp5isVA8CB"
'extract.peer_id': "16Uiu2HAkzXDGenowpuF1qug5uuHJ8fnwz5x2EQeWVQtp5isVA8CB"
'extract.enr': "enr:-MS4QFAWdthn3BhmQC7euQvNr_2AtWqzlzd40q2n7yGtBQJkYEvDZVrVhwd4g9BlQKPfrlX_4W6V-MjrWDy-Qf5iu2sBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpBPtyXhYAAAOADh9QUAAAAAgmlkgnY0gmlwhKwQAAuEcXVpY4IjKYlzZWNwMjU2azGhAku1uBo7WOJ21Oe4jVH76wSUCrlffpBcXjjLhY-jDYQsiHN5bmNuZXRzAIN0Y3CCIyiDdWRwgiMo"
Printing a message
Successfully added 1 CL participants
Printing a message
Start adding validators for participant #1
Printing a message
Using separate validator client for participant #1
Adding service with name 'vc-1-geth-lighthouse' and image 'ethpandaops/lighthouse:stable'
Service 'vc-1-geth-lighthouse' added with service UUID '6ae0c7f8487e47ac98219983728f033f'
Printing a message
NODE JSON RPC URI: '172.16.0.10:8545'
Rendering a template to a files artifact with name 'validator-ranges'
Templates artifact name 'validator-ranges' rendered with artifact UUID 'f3622ee601964c77a68e72d8e7edeeb8'
Starlark code successfully run. Output was:
{
"all_participants": [
{
"cl_context": {
"beacon_grpc_url": "/ip4/172.16.0.11/tcp/9000/p2p/16Uiu2HAkzXDGenowpuF1qug5uuHJ8fnwz5x2EQeWVQtp5isVA8CB",
"beacon_http_url": "http://172.16.0.11:4000",
"beacon_service_name": "cl-1-lighthouse-geth",
"cl_nodes_metrics_info": [
{
"config": {
"labels": null,
"scrape_interval": "15s"
},
"name": "cl-1-lighthouse-geth",
"path": "/metrics",
"url": "172.16.0.11:5054"
}
],
"client_name": "lighthouse",
"enr": "enr:-MS4QFAWdthn3BhmQC7euQvNr_2AtWqzlzd40q2n7yGtBQJkYEvDZVrVhwd4g9BlQKPfrlX_4W6V-MjrWDy-Qf5iu2sBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpBPtyXhYAAAOADh9QUAAAAAgmlkgnY0gmlwhKwQAAuEcXVpY4IjKYlzZWNwMjU2azGhAku1uBo7WOJ21Oe4jVH76wSUCrlffpBcXjjLhY-jDYQsiHN5bmNuZXRzAIN0Y3CCIyiDdWRwgiMo",
"http_port": 4000,
"ip_addr": "172.16.0.11",
"multiaddr": "16Uiu2HAkzXDGenowpuF1qug5uuHJ8fnwz5x2EQeWVQtp5isVA8CB",
"peer_id": false,
"snooper_enabled": null,
"snooper_engine_context": null,
"validator_keystore_files_artifact_uuid": "1-lighthouse-geth-0-63-0"
},
"cl_type": "lighthouse",
"el_context": {
"client_name": "geth",
"el_metrics_info": [
{
"config": {
"labels": null,
"scrape_interval": "15s"
},
"name": "el-1-geth-lighthouse",
"path": "/debug/metrics/prometheus",
"url": "172.16.0.10:9001"
}
],
"engine_rpc_port_num": 8551,
"enode": "enode://17ff80eba12e11fe4d3339303e7d0d5eabf2ec1ad5248a06b136b6602f5b93891d681212e3ea157f7e52a7284c1b2b8d532c18298b94cf3598826f760c2fd8df@172.16.0.10:30303",
"enr": "enr:-Ki4QHFsARFD4V31ZlT5bYsY4P6ovJlmAgqRHNdQTQsr-GAcbE32AWI4V_l7EdMEKZg4OO25K3Bi8EWE_u6T8nUgaOaGAZFivExyg2V0aMzLhJpTGo2FCVeStoKCaWSCdjSCaXCErBAAColzZWNwMjU2azGhAxf_gOuhLhH-TTM5MD59DV6r8uwa1SSKBrE2tmAvW5OJhHNuYXDAg3RjcIJ2X4N1ZHCCdl8",
"ip_addr": "172.16.0.10",
"rpc_http_url": "http://172.16.0.10:8545",
"rpc_port_num": 8545,
"service_name": "el-1-geth-lighthouse",
"ws_port_num": 8546,
"ws_url": "ws://172.16.0.10:8546"
},
"el_type": "geth",
"ethereum_metrics_exporter_context": null,
"snooper_beacon_context": null,
"snooper_engine_context": null,
"vc_context": {
"client_name": "lighthouse",
"metrics_info": {
"config": {
"labels": null,
"scrape_interval": "15s"
},
"name": "vc-1-geth-lighthouse",
"path": "/metrics",
"url": "172.16.0.12:8080"
},
"service_name": "vc-1-geth-lighthouse"
},
"vc_type": "lighthouse",
"xatu_sentry_context": null
}
],
"final_genesis_timestamp": "1723938414",
"genesis_validators_root": "0xd61ea484febacfae5298d52a2b581f3e305a51f3112a9241b968dccf019f7b11",
"network_id": "3151908",
"network_params": {
"additional_preloaded_contracts": {},
"churn_limit_quotient": 65536,
"custody_requirement": 4,
"data_column_sidecar_subnet_count": 128,
"deneb_fork_epoch": 0,
"deposit_contract_address": "0x4242424242424242424242424242424242424242",
"devnet_repo": "ethpandaops",
"eip7594_fork_epoch": 100000001,
"eip7594_fork_version": "0x60000038",
"ejection_balance": 16000000000,
"electra_fork_epoch": 100000000,
"eof_activation_epoch": "",
"eth1_follow_distance": 2048,
"genesis_delay": 20,
"genesis_gaslimit": 30000000,
"max_blobs_per_block": 6,
"max_per_epoch_activation_churn_limit": 8,
"min_validator_withdrawability_delay": 256,
"network": "kurtosis",
"network_id": "3151908",
"network_sync_base_url": "https://snapshots.ethpandaops.io/",
"num_validator_keys_per_node": 64,
"preregistered_validator_count": 0,
"preregistered_validator_keys_mnemonic": "giant issue aisle success illegal bike spike question tent bar rely arctic volcano long crawl hungry vocal artwork sniff fantasy very lucky have athlete",
"preset": "mainnet",
"samples_per_slot": 8,
"seconds_per_slot": 12,
"shard_committee_period": 256
},
"pre_funded_accounts": [
{
"address": "0x8943545177806ED17B9F23F0a21ee5948eCaa776",
"private_key": "bcdf20249abf0ed6d944c0288fad489e33f66b3960d9e6229c1cd214ed3bbe31"
},
{
"address": "0xE25583099BA105D9ec0A67f5Ae86D90e50036425",
"private_key": "39725efee3fb28614de3bacaffe4cc4bd8c436257e2c8bb887c4b5c4be45e76d"
},
{
"address": "0x614561D2d143621E126e87831AEF287678B442b8",
"private_key": "53321db7c1e331d93a11a41d16f004d7ff63972ec8ec7c25db329728ceeb1710"
},
{
"address": "0xf93Ee4Cf8c6c40b329b0c0626F28333c132CF241",
"private_key": "ab63b23eb7941c1251757e24b3d2350d2bc05c3c388d06f8fe6feafefb1e8c70"
},
{
"address": "0x802dCbE1B1A97554B4F50DB5119E37E8e7336417",
"private_key": "5d2344259f42259f82d2c140aa66102ba89b57b4883ee441a8b312622bd42491"
},
{
"address": "0xAe95d8DA9244C37CaC0a3e16BA966a8e852Bb6D6",
"private_key": "27515f805127bebad2fb9b183508bdacb8c763da16f54e0678b16e8f28ef3fff"
},
{
"address": "0x2c57d1CFC6d5f8E4182a56b4cf75421472eBAEa4",
"private_key": "7ff1a4c1d57e5e784d327c4c7651e952350bc271f156afb3d00d20f5ef924856"
},
{
"address": "0x741bFE4802cE1C4b5b00F9Df2F5f179A1C89171A",
"private_key": "3a91003acaf4c21b3953d94fa4a6db694fa69e5242b2e37be05dd82761058899"
},
{
"address": "0xc3913d4D8bAb4914328651C2EAE817C8b78E1f4c",
"private_key": "bb1d0f125b4fb2bb173c318cdead45468474ca71474e2247776b2b4c0fa2d3f5"
},
{
"address": "0x65D08a056c17Ae13370565B04cF77D2AfA1cB9FA",
"private_key": "850643a0224065ecce3882673c21f56bcf6eef86274cc21cadff15930b59fc8c"
},
{
"address": "0x3e95dFbBaF6B348396E6674C7871546dCC568e56",
"private_key": "94eb3102993b41ec55c241060f47daa0f6372e2e3ad7e91612ae36c364042e44"
},
{
"address": "0x5918b2e647464d4743601a865753e64C8059Dc4F",
"private_key": "daf15504c22a352648a71ef2926334fe040ac1d5005019e09f6c979808024dc7"
},
{
"address": "0x589A698b7b7dA0Bec545177D3963A2741105C7C9",
"private_key": "eaba42282ad33c8ef2524f07277c03a776d98ae19f581990ce75becb7cfa1c23"
},
{
"address": "0x4d1CB4eB7969f8806E2CaAc0cbbB71f88C8ec413",
"private_key": "3fd98b5187bf6526734efaa644ffbb4e3670d66f5d0268ce0323ec09124bff61"
},
{
"address": "0xF5504cE2BcC52614F121aff9b93b2001d92715CA",
"private_key": "5288e2f440c7f0cb61a9be8afdeb4295f786383f96f5e35eb0c94ef103996b64"
},
{
"address": "0xF61E98E7D47aB884C244E39E031978E33162ff4b",
"private_key": "f296c7802555da2a5a662be70e078cbd38b44f96f8615ae529da41122ce8db05"
},
{
"address": "0xf1424826861ffbbD25405F5145B5E50d0F1bFc90",
"private_key": "bf3beef3bd999ba9f2451e06936f0423cd62b815c9233dd3bc90f7e02a1e8673"
},
{
"address": "0xfDCe42116f541fc8f7b0776e2B30832bD5621C85",
"private_key": "6ecadc396415970e91293726c3f5775225440ea0844ae5616135fd10d66b5954"
},
{
"address": "0xD9211042f35968820A3407ac3d80C725f8F75c14",
"private_key": "a492823c3e193d6c595f37a18e3c06650cf4c74558cc818b16130b293716106f"
},
{
"address": "0xD8F3183DEF51A987222D845be228e0Bbb932C222",
"private_key": "c5114526e042343c6d1899cad05e1c00ba588314de9b96929914ee0df18d46b2"
},
{
"address": "0xafF0CA253b97e54440965855cec0A8a2E2399896",
"private_key": "4b9f63ecf84210c5366c66d68fa1f5da1fa4f634fad6dfc86178e4d79ff9e59"
}
]
}
⭐ us on GitHub - https://github.com/kurtosis-tech/kurtosis
INFO[2024-08-18T07:46:36+08:00] ===================================================
INFO[2024-08-18T07:46:36+08:00] || Created enclave: my-testnet ||
INFO[2024-08-18T07:46:36+08:00] ===================================================
Name: my-testnet
UUID: 42cd007733fd
Status: RUNNING
Creation Time: Sun, 18 Aug 2024 07:45:48 CST
Flags:
========================================= Files Artifacts =========================================
UUID Name
f3cec89e643f 1-lighthouse-geth-0-63-0
4d06c21f3ace el_cl_genesis_data
b9bf7209e5e0 final-genesis-timestamp
6136dacb9ca0 genesis-el-cl-env-file
5c2c3ba976e2 genesis_validators_root
07de89efaab2 jwt_file
9b1313c32b66 keymanager_file
66139157e680 prysm-password
f3622ee60196 validator-ranges
========================================== User Services ==========================================
UUID Name Ports Status
3c8393ddc369 cl-1-lighthouse-geth http: 4000/tcp -> http://127.0.0.1:32787 RUNNING
metrics: 5054/tcp -> http://127.0.0.1:32786
tcp-discovery: 9000/tcp -> 127.0.0.1:32785
udp-discovery: 9000/udp -> 127.0.0.1:32771
1820eff8ef77 el-1-geth-lighthouse engine-rpc: 8551/tcp -> 127.0.0.1:32782 RUNNING
metrics: 9001/tcp -> http://127.0.0.1:32781
rpc: 8545/tcp -> 127.0.0.1:32784
tcp-discovery: 30303/tcp -> 127.0.0.1:32780
udp-discovery: 30303/udp -> 127.0.0.1:32770
ws: 8546/tcp -> 127.0.0.1:32783
41622a2db8f1 validator-key-generation-cl-validator-keystore <none> RUNNING
6ae0c7f8487e vc-1-geth-lighthouse metrics: 8080/tcp -> http://127.0.0.1:32788 RUNNING
将测试网导入到 MetaMask 中
很明显从上面打印的信息我们可以获取到以下信息:
network
字段的值为kurtosis
。network_id
为3151908
。(默认配置链 ID 为 3151908)- 链的 RPC 地址 为
rpc: 8545/tcp -> 127.0.0.1:32784
。(这个在User Services
中的el-1-geth-lighthouse
中)。注意:这里的127.0.0.1:32784
应该转成你搭建私链的公网 IP + 端口,并且填入MetaMask
时要加入 HTTP/HTTPS 前缀。
大家可以仔细的看看上述打印出来的信息,相信不难就能找到我说的这三个信息。
(如果实在找不到,可以将打印信息从终端拷到文档然后使用 Ctrl+F
搜索 network
、network_id
和 User Services
)
然后我们将获得的信息分别填入到 MetaMask
中,然后就可以连接到搭建好的 Kurtosis 私链。
导入已有的账户
如上述打印的信息我们可以很清晰地获取到以下 20 个账户,每个账户都有 1000000000ETH余额可供我们测试,我们只需要将它们用私钥导入到 MetaMask 中即可使用。
进入Geth Console
使用以下命令可以访问 my-testnet
的 shell 权限。
kurtosis service shell my-testnet el-1-geth-lighthouse
在 shell 中 输入以下命令即可进入 Kurtosis 私链中的控制台
geth --datadir /data/geth/execution-data/ attach
以下信息代表进入成功。
No bash found on container; dropping down to sh shell...
/ # geth --datadir /data/geth/execution-data/ attach
Welcome to the Geth JavaScript console!
instance: Geth/v1.14.9-unstable-710c3f32/linux-amd64/go1.22.6
at block: 165 (Sun Aug 18 2024 00:20:14 GMT+0000 (UTC))
datadir: /data/geth/execution-data
modules: admin:1.0 debug:1.0 engine:1.0 eth:1.0 miner:1.0 net:1.0 rpc:1.0 txpool:1.0 web3:1.0
To exit, press ctrl-d or type exit
在控制台中编写监听脚本来监听区块信息
在上一步进入 Geth Console 后,我们可以使用以下 JavaScript 脚本 在 Geth 控制台中监听所有新生成的区块,并打印它们的完整信息。
var filter = eth.filter('latest');
filter.watch(function(error, result) {
if (!error) {
var block = eth.getBlock(result);
console.log("==========================================");
console.log("Block Number: " + block.number);
console.log("Block Hash: " + block.hash);
console.log("Parent Hash: " + block.parentHash);
console.log("Nonce: " + block.nonce);
console.log("Sha3Uncles: " + block.sha3Uncles);
console.log("LogsBloom: " + block.logsBloom);
console.log("TransactionsRoot: " + block.transactionsRoot);
console.log("StateRoot: " + block.stateRoot);
console.log("Miner: " + block.miner);
console.log("Difficulty: " + block.difficulty);
console.log("Total Difficulty: " + block.totalDifficulty);
console.log("Extra Data: " + block.extraData);
console.log("Size: " + block.size);
console.log("Gas Limit: " + block.gasLimit);
console.log("Gas Used: " + block.gasUsed);
console.log("Timestamp: " + new Date(block.timestamp * 1000));
console.log("Transactions: " + block.transactions);
console.log("Uncles: " + block.uncles);
console.log("==========================================");
} else {
console.error(error);
}
});
要停止打印区块信息,可以使用以下命令停止过滤器
filter.stopWatching();
使用 Ctrl+C
可以退出 Geth 控制台,使用 exit
可以退出 Kurtosis shell 界面。