<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                以太坊(英文Ethereum)是一個開源的有智能合約功能的公共區塊鏈平臺,通過其專用加密貨幣以太幣(Ether,簡稱“ETH”)提供去中心化的以太虛擬機(Ethereum Virtual Machine)來處理點對點合約。 ### 節點搭建 配置文件如下 ``` [program:eth_node] command=/home/ubuntu/bin/geth --rpc --rpcapi web3,eth,net,db,personal,admin --rpcaddr 0.0.0.0 --rpcport 8545 --maxpeers 100 autostart=true autorestart=true startsecs=5 priority=1 stopasgroup=true killasgroup=true user=ubuntu stderr_logfile=/home/ubuntu/data/eth_stderr.log stdout_logfile=/home/ubuntu/data/eth_stdout.log ``` # Geth Documentation You have found the user manual for geth, the Go language implementation of Ethereum. - [Getting Started Guide](https://geth.ethereum.org/docs/getting-started) - [Installation Instructions](https://geth.ethereum.org/docs/install-and-build/installing-geth) - [JSON-RPC Server](https://geth.ethereum.org/docs/rpc/server) - [JavaScript Console](https://geth.ethereum.org/docs/interface/javascript-console) For the Go API reference and developer documentation head over to [GoDoc](https://godoc.org/github.com/ethereum/go-ethereum). ### Other Ethereum Documentation For generic Ethereum-related information, check the **[Ethereum Wiki](https://github.com/ethereum/wiki/wiki)**. - [Ethereum Whitepaper](https://github.com/ethereum/wiki/wiki/White-Paper) - [Ethereum Yellow Paper](https://ethereum.github.io/yellowpaper/paper.pdf) - [Ethereum Improvement Proposals (EIPs)](https://eips.ethereum.org/) - [Peer-to-peer Networking Specifications](https://github.com/ethereum/devp2p/blob/master/README.md) 參考網站: https://geth.ethereum.org/docs/ --- ## 用戶 - 打開控制臺 ``` $ geth --datadir=path/to/custom/data/folder attach --datadir“~/.ethereum”數據庫和密鑰庫的數據目錄 ``` - 創建賬戶,參數是密碼 ``` 在控制臺輸入下面命令: personal.newAccount("Write here a good, randomly generated, passphrase!") "0x0fec688d601909d28faf6fe18cf6230d08b698b6" 默認第一個創建的用戶為主用戶 ``` 查看用戶: ``` eth.accounts ["0x0fec688d601909d28faf6fe18cf6230d08b698b6"] 賬戶的排序反映了他們創建的時間。 密鑰文件存儲在DATADIR / keystore下,可以通過復制其中包含的文件在客戶端之間傳輸。 這些文件使用密碼加密,如果它們包含任何數量的以太網,則應備份。 但是,請注意,如果您傳輸個別密鑰文件,則提交的帳戶順序可能會發生變化,您可能無法在同一位置結束同一帳戶。 因此請注意,只要您不將外部密鑰文件復制到您的密鑰存儲區,只依賴帳戶索引即可。 ``` - 解鎖帳戶 ``` personal.unlockAccount("0x42080eed689d8a60f02e8dc8bee6d67a8262fdea") 或者 這里是給第一個賬戶解鎖 user1=eth.accounts[0] personal.unlockAccount(user1) ``` ### 賬戶 ``` USAGE: geth account command [command options] [arguments...] COMMANDS: list 列出所有帳戶的簡要信息 new 創建一個新賬戶 update 更新現有賬戶 import 將私鑰導入一個新帳戶 OPTIONS: --help, -h show help ``` ### geth account list 列出所有帳戶的簡要信息 ``` list [command options] [arguments...]列出所有帳戶的簡要信息ETHEREUM OPTIONS: --datadir "/root/.ethereum" 數據庫和密鑰庫的數據目錄 --keystore 密鑰庫目錄 (默認同datadir) ``` 示例: ``` > geth account list --datadir "/root/Documents/ethereum/data/"INFO [04-09|00:56:47] Maximum peer count ETH=25 LES=0 total=25Account #0: {93a44e1e0aceb6a68ed39018d48a359b0beb8eb5} keystore:///root/Documents/ethereum/data/keystore/UTC--2018-03-28T06-14-55.548233530Z--93a44e1e0aceb6a68ed39018d48a359b0beb8eb5Account #1: {68512ebacb81a3274933de1ac02a787927ef76d5} keystore:///root/Documents/ethereum/data/keystore/UTC--2018-03-29T07-38-29.214491449Z--68512ebacb81a3274933de1ac02a787927ef76d5 ``` #### geth account new ``` new [command options] [arguments...] geth account new創建一個新帳戶并打印地址。該帳戶以加密格式保存,系統會提示您輸入密碼。您必須記住此密碼才能在未來解鎖您的帳戶。對于非交互式使用,可以使用--password 選項來指定密碼請注意,這種方式僅用于測試,因為將密碼保存到文件或以任何其他方式公開都是一個壞主意。ETHEREUM OPTIONS: --datadir "/root/.ethereum" 數據庫和密鑰庫的數據目錄 --keystore 密鑰庫目錄 (默認同datadir) --lightkdf 以減少KDF(秘鑰生成函數)的強度為代價減少生成秘鑰時RAM和CPU的使用量ACCOUNT OPTIONS: --password value 用于非交互式密碼輸入時指定密碼文件 ``` 示例: ``` > geth account new --datadir "/root/Documents/ethereum/data/"INFO [04-09|01:15:46] Maximum peer count ETH=25 LES=0 total=25Your new account is locked with a password. Please give a password. Do not forget this password.Passphrase:Repeat passphrase:Address: {0ed90cf4d6a37cbcf7c4b9461f151c6f1fe2284b}> geth account list --datadir "/root/Documents/ethereum/data/"INFO [04-09|01:16:09] Maximum peer count ETH=25 LES=0 total=25Account #0: {93a44e1e0aceb6a68ed39018d48a359b0beb8eb5} keystore:///root/Documents/ethereum/data/keystore/UTC--2018-03-28T06-14-55.548233530Z--93a44e1e0aceb6a68ed39018d48a359b0beb8eb5Account #1: {68512ebacb81a3274933de1ac02a787927ef76d5} keystore:///root/Documents/ethereum/data/keystore/UTC--2018-03-29T07-38-29.214491449Z--68512ebacb81a3274933de1ac02a787927ef76d5Account #2: {0ed90cf4d6a37cbcf7c4b9461f151c6f1fe2284b} keystore:///root/Documents/ethereum/data/keystore/UTC--2018-04-09T08-15-58.475205640Z--0ed90cf4d6a37cbcf7c4b9461f151c6f1fe2284b ``` 使用密碼文件的方式: /root/Documents/ethereum/pwd 的內容是一個密碼的字符串 ``` > geth account new --datadir "/root/Documents/ethereum/data/" --password "/root/Documents/ethereum/pwd"INFO [04-09|01:17:44] Maximum peer count ETH=25 LES=0 total=25Address: {f96a0654d887881cd8cdd5c4320125ae90515a0d}> geth account list --datadir "/root/Documents/ethereum/data/"INFO [04-09|01:17:49] Maximum peer count ETH=25 LES=0 total=25Account #0: {93a44e1e0aceb6a68ed39018d48a359b0beb8eb5} keystore:///root/Documents/ethereum/data/keystore/UTC--2018-03-28T06-14-55.548233530Z--93a44e1e0aceb6a68ed39018d48a359b0beb8eb5Account #1: {68512ebacb81a3274933de1ac02a787927ef76d5} keystore:///root/Documents/ethereum/data/keystore/UTC--2018-03-29T07-38-29.214491449Z--68512ebacb81a3274933de1ac02a787927ef76d5Account #2: {0ed90cf4d6a37cbcf7c4b9461f151c6f1fe2284b} keystore:///root/Documents/ethereum/data/keystore/UTC--2018-04-09T08-15-58.475205640Z--0ed90cf4d6a37cbcf7c4b9461f151c6f1fe2284bAccount #3: {f96a0654d887881cd8cdd5c4320125ae90515a0d} keystore:///root/Documents/ethereum/data/keystore/UTC--2018-04-09T08-17-44.504001170Z--f96a0654d887881cd8cdd5c4320125ae90515a0d ``` #### geth account update ``` update [command options] [arguments...] geth account update <address>更新現有帳戶。要更新的帳戶以加密格式保存在最新版本中,系統會提示您輸入密碼以解鎖帳戶,然后再輸入新密碼,就會把新密碼更新到存儲文件。使用本命令可以用于將老格式的帳戶遷移至最新格式或更改帳戶的密碼。對于非交互式使用,可以使用--password 選項來指定新密碼: geth account update [options] <address>由于只能輸入一個密碼,只能進行格式更新,所以更改密碼是唯一的交互方式。ETHEREUM OPTIONS: --datadir "/root/.ethereum" 數據庫和密鑰庫的數據目錄 --keystore 密鑰庫目錄 (默認同datadir) --lightkdf 以減少KDF(秘鑰生成函數)的強度為代價減少生成秘鑰時RAM和CPU的使用量 ``` > 我理解的這里的格式修改,是指隨著geth版本升級,對賬戶的構成方式(生成秘鑰的方式等)發生了變化,此時需要適配新版本。把老版本用戶進行更新。實際中未遇到此類情況。歡迎理解的童鞋不吝賜教。 示例: ``` > geth account update f96a0654d887881cd8cdd5c4320125ae90515a0d --datadir "/root/Documents/ethereum/data/"INFO [04-09|01:36:07] Maximum peer count ETH=25 LES=0 total=25Unlocking account f96a0654d887881cd8cdd5c4320125ae90515a0d | Attempt 1/3Passphrase:INFO [04-09|01:36:11] Unlocked account address=0xf96a0654D887881cd8cDD5c4320125aE90515A0DPlease give a new password. Do not forget this password.Passphrase:Repeat passphrase: ``` #### geth account import ``` import [command options] [arguments...] geth account import <keyfile>從<keyfile>導入一個未加密的私鑰并創建一個新帳戶。返回新創建用戶的地址。這個密鑰文件(keyfile)需要包含十六進制格式的未加密私鑰。該帳戶將以加密格式保存,系統會提示您輸入密碼。您必須記住此密碼才能在未來解鎖您的帳戶。對于非交互式使用,可以使用--password 選項來指定新密碼: geth account import [options] <keyfile>注意:由于您可以直接將加密帳戶復制到另一個以太坊實例,因此在節點之間傳輸帳戶時不需要此導入機制。ETHEREUM OPTIONS: --datadir "/root/.ethereum" 數據庫和密鑰庫的數據目錄 --keystore 密鑰庫目錄 (默認同datadir) --lightkdf 以減少KDF(秘鑰生成函數)的強度為代價減少生成秘鑰時RAM和CPU的使用量ACCOUNT OPTIONS: --password value 用于非交互式密碼輸入時指定密碼文件 ``` ### 挖礦 - 開始挖礦 ``` miner.start() 挖到一個區塊會獎勵5個以太幣,挖礦所得的獎勵會進入礦工的賬戶,這個賬戶叫做coinbase,默認情況下coinbase是本地賬戶中的第一個賬戶: ``` - 查看挖礦進賬用戶 ``` eth.coinbase "0xf9ab190a9c56fd0d945eac9659c0c9519b13c64e" 現在的coinbase是賬戶0,要想使挖礦獎勵進入其他賬戶,通過miner.setEtherbase()將其他賬戶設置成coinbase即可 ``` - 設置挖礦用戶 ``` miner.setEtherbase(eth.accounts[1]) true eth.coinbase "0xb89bf2a212484ef9f1bd09efcd57cf37dbb1e52f" ``` - 停止挖礦 ``` miner.stop() true ``` - 檢查挖礦是否已經停止,eth.mining 輸出為false時表示挖礦已經停止 ``` eth.mining false ``` ### 交易 - 查看帳號余額 eth.getBalance(eth.accounts[0]) getBalance()返回值的單位是wei,wei是以太幣的最小單位,1個以太幣=10的18次方個wei。要查看有多少個以太幣,可以用web3.fromWei()將返回值換算成以太幣: ``` web3.fromWei(eth.getBalance(eth.accounts[0]),'ether') 340 單位轉換: Ether– Wei web3.toWei(1) 單位轉換: Wei – Ether web3.fromWei(10000000000000000) ``` - 轉賬 轉賬前需要解鎖帳號,就像輸入銀行卡號密碼 ``` eth.sendTransaction({"from":"0x67128734480a0741595538d9d726f33addf83978", "to":"0x29a9a6bcf1ce7101ab93a029e2692298fc15e076", "gas":31000,"gasPrice":web3.toWei(300,'gwei'),"value":"1"}) "0x54325698db1fbc85799b2f72070cddc457932abf0eef0d30d4fb2710ddafa941" eth.sendTransaction({"from":"0x67128734480a0741595538d9d726f33addf83978", "to":"0x29a9a6bcf1ce7101ab93a029e2692298fc15e076", "value":"10000000000000000000000"}) "0x533d3c770aed09ede826c92e7460fd38d78a101752a7b3b25e4470d8594e77bb" ``` - 查看當前區塊總數: eth.blockNumber 69 - 通過區塊號查看區塊里打包的交易信息 ``` eth.getBlock(6) { difficulty: 2, extraData: "0xd783010803846765746887676f312e392e32856c696e75780000000000000000cff7302b0c5515614e52f1584ff3f6aceb10dfa6e2facb347bfe3c023878d3857fa48774a98c721bcc1fb2419a177d577a0926e9f51d037095ba53257f7f307701", gasLimit: 6246618, gasUsed: 21000, hash: "0x5e2506ce385e38bbe23765a24ec25f9742e4a3a5af7cd071088081535a6a0dd2", logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", miner: "0x0000000000000000000000000000000000000000", mixHash: "0x0000000000000000000000000000000000000000000000000000000000000000", nonce: "0x0000000000000000", number: 6, parentHash: "0x716da23fef7103042762025aabc83f7075fca516ab9dc6d436daa58b8350953b", receiptsRoot: "0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2", sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", size: 713, stateRoot: "0x7c93a037c0750ddca8330d9c84912c622cd355c6978fc4267ffe2c8517a32469", timestamp: 1520398599, totalDifficulty: 13, transactions: ["0x54325698db1fbc85799b2f72070cddc457932abf0eef0d30d4fb2710ddafa941"], transactionsRoot: "0x712b5bba767dd0ecaeebbbeefdf097647a0f219f11f16e4a8a3d768b59ae442e", uncles: [] } ``` - 通過交易hash查看交易 ``` eth.getTransaction("0x54325698db1fbc85799b2f72070cddc457932abf0eef0d30d4fb2710ddafa941") { blockHash: "0x5e2506ce385e38bbe23765a24ec25f9742e4a3a5af7cd071088081535a6a0dd2", blockNumber: 6, from: "0x67128734480a0741595538d9d726f33addf83978", gas: 31000, gasPrice: 300000000000, hash: "0x54325698db1fbc85799b2f72070cddc457932abf0eef0d30d4fb2710ddafa941", input: "0x", nonce: 5, r: "0xe14faca3d11a47ec4617927c84a04936dbaf783cc2187794e04299ce04352404", s: "0x6da16b4e07a4fc721273d3b09da1c8b29ad4ce8022a99eb3f8317247cf7f5386", to: "0x29a9a6bcf1ce7101ab93a029e2692298fc15e076", transactionIndex: 0, v: "0xa95", value: 1 } ``` - 查看交易狀態 txpool.status { pending: 0, queued: 0 } ## 算法 1.以太坊Geth客戶端命令 ```js geth attach # eth.blockNumber # net.peerCount # eth.accounts # 查看所有賬戶 # account ``` 2.地址私鑰對產生算法 ```c++ privateKey, err := crypto.GenerateKey() if err != nil { log.Fatal(err) } privateKeyBytes := crypto.FromECDSA(privateKey) fmt.Println(hexutil.Encode(privateKeyBytes)[2:]) publicKey := privateKey.Public() publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey) if !ok { log.Fatal("cannot assert type: publicKey is not of type *ecdsa.PublicKey") } publicKeyBytes := crypto.FromECDSAPub(publicKeyECDSA) fmt.Println(hexutil.Encode(publicKeyBytes)[4:]) address := crypto.PubkeyToAddress(*publicKeyECDSA).Hex() fmt.Println(address) //hash := sha3.NewKeccak256() hash := sha3.NewLegacyKeccak256() hash.Write(publicKeyBytes[1:]) fmt.Println(hexutil.Encode(hash.Sum(nil)[12:])) ``` ## 節點升級 1.9.7版本:wget https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.9.7-a718daa6.tar.gz 1.9.9版本:wget https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.9.9-01744997.tar.gz ## 附錄 - Parity API官方:https://wiki.parity.io/JSONRPC-eth-module.html - 以太坊系列:https://www.huweihuang.com/article/ethereum/ethereum-account-management/ ## 命令用法 ``` geth [選項] 命令 [命令選項] [參數…] ``` ### 版本: ``` 1.7.3-stable ``` ### 命令: ``` account 管理賬戶 attach 啟動交互式JavaScript環境(連接到節點) bug 上報bug Issues console 啟動交互式JavaScript環境 copydb 從文件夾創建本地鏈 dump Dump(分析)一個特定的塊存儲 dumpconfig 顯示配置值 export 導出區塊鏈到文件 import 導入一個區塊鏈文件 init 啟動并初始化一個新的創世紀塊 js 執行指定的JavaScript文件(多個) license 顯示許可信息 makecache 生成ethash驗證緩存(用于測試) makedag 生成ethash 挖礦DAG(用于測試) monitor 監控和可視化節點指標 removedb 刪除區塊鏈和狀態數據庫 version 打印版本號 wallet 管理Ethereum預售錢包 help,h 顯示一個命令或幫助一個命令列表 ``` ### ETHEREUM選項: ``` --config value TOML 配置文件 --datadir “xxx” 數據庫和keystore密鑰的數據目錄 --keystore keystore存放目錄(默認在datadir內) --nousb 禁用監控和管理USB硬件錢包 --networkid value 網絡標識符(整型, 1=Frontier, 2=Morden (棄用), 3=Ropsten, 4=Rinkeby) (默認: 1) --testnet Ropsten網絡:預先配置的POW(proof-of-work)測試網絡 --rinkeby Rinkeby網絡: 預先配置的POA(proof-of-authority)測試網絡 --syncmode "fast" 同步模式 ("fast", "full", or "light") --ethstats value 上報ethstats service URL (nodename:secret@host:port) --identity value 自定義節點名 --lightserv value 允許LES請求時間最大百分比(0 – 90)(默認值:0) --lightpeers value 最大LES client peers數量(默認值:20) --lightkdf 在KDF強度消費時降低key-derivation RAM&CPU使用 ``` ### 開發者(模式)選項: ``` --dev 使用POA共識網絡,默認預分配一個開發者賬戶并且會自動開啟挖礦。 --dev.period value 開發者模式下挖礦周期 (0 = 僅在交易時) (默認: 0) ``` ### ETHASH 選項: ``` --ethash.cachedir ethash驗證緩存目錄(默認 = datadir目錄內) --ethash.cachesinmem value 在內存保存的最近的ethash緩存個數 (每個緩存16MB ) (默認: 2) --ethash.cachesondisk value 在磁盤保存的最近的ethash緩存個數 (每個緩存16MB) (默認: 3) --ethash.dagdir "" 存ethash DAGs目錄 (默認 = 用戶hom目錄) --ethash.dagsinmem value 在內存保存的最近的ethash DAGs 個數 (每個1GB以上) (默認: 1) --ethash.dagsondisk value 在磁盤保存的最近的ethash DAGs 個數 (每個1GB以上) (默認: 2) ``` ### 交易池選項: ``` --txpool.nolocals 為本地提交交易禁用價格豁免 --txpool.journal value 本地交易的磁盤日志:用于節點重啟 (默認: "transactions.rlp") --txpool.rejournal value 重新生成本地交易日志的時間間隔 (默認: 1小時) --txpool.pricelimit value 加入交易池的最小的gas價格限制(默認: 1) --txpool.pricebump value 價格波動百分比(相對之前已有交易) (默認: 10) --txpool.accountslots value 每個帳戶保證可執行的最少交易槽數量 (默認: 16) --txpool.globalslots value 所有帳戶可執行的最大交易槽數量 (默認: 4096) --txpool.accountqueue value 每個帳戶允許的最多非可執行交易槽數量 (默認: 64) --txpool.globalqueue value 所有帳戶非可執行交易最大槽數量 (默認: 1024) --txpool.lifetime value 非可執行交易最大入隊時間(默認: 3小時) ``` ### 性能調優的選項: ``` --cache value 分配給內部緩存的內存MB數量,緩存值(最低16 mb /數據庫強制要求)(默認:128) --trie-cache-gens value 保持在內存中產生的trie node數量(默認:120) ``` ### 帳戶選項: ``` --unlock value 需解鎖賬戶用逗號分隔 --password value 用于非交互式密碼輸入的密碼文件 ``` ### API和控制臺選項: ``` --rpc 啟用HTTP-RPC服務器 --rpcaddr value HTTP-RPC服務器接口地址(默認值:“localhost”) --rpcport value HTTP-RPC服務器監聽端口(默認值:8545) --rpcapi value 基于HTTP-RPC接口提供的API --ws 啟用WS-RPC服務器 --wsaddr value WS-RPC服務器監聽接口地址(默認值:“localhost”) --wsport value WS-RPC服務器監聽端口(默認值:8546) --wsapi value 基于WS-RPC的接口提供的API --wsorigins value websockets請求允許的源 --ipcdisable 禁用IPC-RPC服務器 --ipcpath 包含在datadir里的IPC socket/pipe文件名(轉義過的顯式路徑) --rpccorsdomain value 允許跨域請求的域名列表(逗號分隔)(瀏覽器強制) --jspath loadScript JavaScript加載腳本的根路徑(默認值:“.”) --exec value 執行JavaScript語句(只能結合console/attach使用) --preload value 預加載到控制臺的JavaScript文件列表(逗號分隔) ``` ### 網絡選項: ``` --bootnodes value 用于P2P發現引導的enode urls(逗號分隔)(對于light servers用v4+v5代替) --bootnodesv4 value 用于P2P v4發現引導的enode urls(逗號分隔) (light server, 全節點) --bootnodesv5 value 用于P2P v5發現引導的enode urls(逗號分隔) (light server, 輕節點) --port value 網卡監聽端口(默認值:30303) --maxpeers value 最大的網絡節點數量(如果設置為0,網絡將被禁用)(默認值:25) --maxpendpeers value 最大嘗試連接的數量(如果設置為0,則將使用默認值)(默認值:0) --nat value NAT端口映射機制 (any|none|upnp|pmp|extip:<IP>) (默認: “any”) --nodiscover 禁用節點發現機制(手動添加節點) --v5disc 啟用實驗性的RLPx V5(Topic發現)機制 --nodekey value P2P節點密鑰文件 --nodekeyhex value 十六進制的P2P節點密鑰(用于測試) ``` ### 礦工選項: ``` --mine 打開挖礦 --minerthreads value 挖礦使用的CPU線程數量(默認值:8) --etherbase value 挖礦獎勵地址(默認=第一個創建的帳戶)(默認值:“0”) --targetgaslimit value 目標gas限制:設置最低gas限制(低于這個不會被挖?) (默認值:“4712388”) --gasprice value 挖礦接受交易的最低gas價格 --extradata value 礦工設置的額外塊數據(默認=client version) ``` ### GAS價格選項: ``` --gpoblocks value 用于檢查gas價格的最近塊的個數 (默認: 10) --gpopercentile value 建議gas價參考最近交易的gas價的百分位數,(默認: 50) ``` ### 虛擬機的選項: ``` --vmdebug 記錄VM及合約調試信息 ``` ### 日志和調試選項: ``` --metrics 啟用metrics收集和報告 --fakepow 禁用proof-of-work驗證 --verbosity value 日志詳細度:0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=detail (default: 3) --vmodule value 每個模塊詳細度:以 <pattern>=<level>的逗號分隔列表 (比如 eth/*=6,p2p=5) --backtrace value 請求特定日志記錄堆棧跟蹤 (比如 “block.go:271”) --debug 突出顯示調用位置日志(文件名及行號) --pprof 啟用pprof HTTP服務器 --pprofaddr value pprof HTTP服務器監聽接口(默認值:127.0.0.1) --pprofport value pprof HTTP服務器監聽端口(默認值:6060) --memprofilerate value 按指定頻率打開memory profiling (默認:524288) --blockprofilerate value 按指定頻率打開block profiling (默認值:0) --cpuprofile value 將CPU profile寫入指定文件 --trace value 將execution trace寫入指定文件 ``` ### WHISPER實驗選項: ``` --shh 啟用Whisper --shh.maxmessagesize value 可接受的最大的消息大小 (默認值: 1048576) --shh.pow value 可接受的最小的POW (默認值: 0.2) ``` ### 棄用選項: ``` --fast 開啟快速同步 --light 啟用輕客戶端模式 ``` ### 其他選項: ``` –help, -h 顯示幫助 ``` ### 版權: ``` Copyright 2013-2017 The go-ethereum Authors ``` # 問題收集 ethereum 報錯匯總, 包含一些自己遇到的和網上收集的報錯。 ## 問題收集 ### go-ethereum 以太坊編譯時報錯:undefined reference to `libiconv' 參考地址:https://shaohualee.com/article/890 ``` make geth build/env.sh go run build/ci.go install ./cmd/geth >>> /usr/local/go/bin/go install -ldflags -X main.gitCommit=1db4ecdc0b9e828ff65777fb466fc7c1d04e0de9 -v ./cmd/geth github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid # github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid /tmp/go-build267146492/github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid/_obj/hid_enabled.cgo2.o: In function `get_usb_string': hid_enabled.cgo2.c:(.text+0x94d4): undefined reference to `libiconv_open' hid_enabled.cgo2.c:(.text+0x9523): undefined reference to `libiconv' hid_enabled.cgo2.c:(.text+0x954f): undefined reference to `libiconv_close' collect2: error: ld returned 1 exit status util.go:44: exit status 2 exit status 1 make: *** [geth] Error 1 ``` 只要這一步神操作就可以了: ``` rm /usr/local/include/iconv.h #最好是適用mv哈。mv /usr/local/include/iconv.h /usr/local/include/iconv.h.back ``` ### 以太坊的手續費計算 在以太坊發出交易或者其他一些東西的時候,如果手續費計算有問題或者沒有在此之前半段賬戶余額是不是充足,便會碰到“insufficient funds for gas * price + value”異常。今天就帶大家看看源代碼分析一下此異常的始末。 手續費不足異常 手續費不足的異常情況,意思就是發起交易所需手續費超過了地址中的余額,因為我們知道發起交易需的手續費是由gasLimit和gasPrice組成,即它們的乘積。然而交易一旦發出之后,實際消費的手續費卻是由gasPrice和交易的字節數決定的。 我們先看一下異常信息: `Insufficient funds for gas * price + value` 、這條異常信息就是告訴我們:當前地址的余額不足以支付gasLimit乘以gasPrice再加上轉賬的value值。異常中的gas指的就是gasLimit,price就是gasPrice,value指的是發起交易轉賬的以太幣。 源代碼分析 異常定義代碼,注釋部分已經很明確的說明了異常信息發生的情況: ```js // ErrInsufficientFunds is returned if the total cost of executing a transaction // is higher than the balance of the user‘s account. ErrInsufficientFunds = errors.New(“insufficient funds for gas * price + value“) 調用檢驗金額代碼: // Transactor should have enough funds to cover the costs // cost == V + GP * GL if pool.currentState.GetBalance(from).Cmp(tx.Cost()) < 0 { return ErrInsufficientFunds } 再看一下tx.Cost是如何計算獲取得到的: // Cost returns amount + gasprice * gaslimit. func (tx *Transaction) Cost() *big.Int { total := new(big.Int).Mul(tx.data.Price, new(big.Int).SetUint64(tx.data.GasLimit)) total.Add(total, tx.data.Amount) return total } ``` 很明顯代碼中也是通過amount加上gasprice和gaslimit的乘積然后和余額進行比較。 其他情況 還有一些其他原因引起的此異常。比如有同學說,我通過區塊鏈瀏覽器查詢地址上余額足夠,通過上面的公式計算獲得的金額也小于余額,但每次通過節點發送交易,都會拋出此異常。 針對這個問題,需要做的第一步排查就是:發出交易的節點是否同步到了賬戶的余額,不是通過區塊鏈瀏覽器查詢余額,而是要直接在本地節點中查詢余額。 ### account unlock with HTTP access is forbidden > 使用geth 客戶端,當執行personal.unlockAccount()或在程序中調用personal_unlockAccount接口時,會出現:account unlock with HTTP access is forbidden異常。 異常分析 出于安全考慮,默認禁止了HTTP通道解鎖賬戶,相關issue:https://github.com/ethereum/go-ethereum/pull/17037 解決方法 如果已經了解打開此功能的風險,可通啟動命令中添加參數: `--allow-insecure-unlock` 舉例: ``` geth --datadir data0 --rpc --rpcaddr 127.0.0.1 --rpcport 8545 --allow-insecure-unlock console ``` 參考:https://blog.csdn.net/Toufahaizai/article/details/101426500 ### invalid sender undefined 這個錯誤不會導致初始化失敗,但是會在以后的轉賬(eth.sendTransaction),或者部署智能合約的時候產生。解決方法就是在genesis.json文件中,chainId 不能設置為0。 如果你完全按照github上給的官方配置文件,就會產生這個錯誤 ### Error: authentication needed: password or unlock undefined 解鎖賬戶:personal.unlockAccount(acc0) ### Error: exceeds block gas limit undefined. The contract code couldn’t be stored, please check your gas amount. undefined 把合約中gas改為300000。直接從那個網站的Web3 deploy 復制可能是4300000,然后改成300000,就沒問題了。 ### Fatal: invalid genesis file: missing 0x prefix for hex data 這個錯誤信息意思很明白,就是你的json文件中,對于16進制數據,需要加上0x前綴 ### Fatal: invalid genesis file: hex string has odd length 從v1.6開始,設置的十六進制數值,不能是奇數位, 比如不能是0x0,而應該是0x00。 ### Fatal: failed to write genesis block: genesis has no chain configuration 這個錯誤信息,就是說,你的json文件中,缺少config部分。看到這個信息,我們不需要把geth退回到v1.5版本,而是需要加上config部分 參考文檔: 1. https://blog.csdn.net/loy_184548/article/details/78002015 2. [http://blog.leanote.com/post/chaim/%E4%BB%A5%E5%A4%AA%E5%9D%8A%E7%A0%94%E7%A9%B6%E3%80%90%E5%AE%89%E8%A3%85%E3%80%91](http://blog.leanote.com/post/chaim/以太坊研究【安裝】) 3. https://github.com/ethereum/go-ethereum/issues/15983
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看