laalaguer / ethereum-compass Goto Github PK
View Code? Open in Web Editor NEW《以太坊的指南针》 一本写给普通人看的以太坊区块链技术书。A Book of Ethereum in Chinese.
Home Page: http://ethbook.abyteahead.com/
《以太坊的指南针》 一本写给普通人看的以太坊区块链技术书。A Book of Ethereum in Chinese.
Home Page: http://ethbook.abyteahead.com/
原文
将这个数据集的键(例如 dog)和值(例如 0)按照 Radix 树状结构组织起来
应该改为
将这个数据集的键(例如 dog)和值(例如 1)按照 Radix 树状结构组织起来
第5章中的“启动一条以太坊私链”
其中geth命令的多个参数已经过时,得用新的参数名称
--rpc 改为 --http
--rpcaddr 改为 --http.addr
--rpcport 改为 --http.port
--rpccorsdomain 改为 --http.corsdomain
--rpcapi 改为 --http.api
--minerthreads 改为 --miner.threads
--etherbase 改为 --miner.etherbase
修改过后的命令行是这样
geth --datadir ./db/ --http --http.addr=127.0.0.1 --http.port 8545 --http.corsdomain "*"
--http.api "eth,net,web3,personal,admin,shh,txpool,debug,miner"
--nodiscover --maxpeers 30 --networkid 198989 --port 30303
--mine --miner.threads 1
--miner.etherbase "0x7df9a875a174b3bc565e6424a0050ebc1b2d1d82"
console
另外,现在挖到矿之后,只会显示 mined potential block
而不再有小锤子的图标
现在创世配置和以前不一样了
必须加上 eip150Block
不然初始化时会报错
"Fatal: Failed to write genesis block: unsupported fork ordering: eip150Block not enabled, but eip155Block enabled at 0"
修正后的配置是这样
{
"config": {
"chainId": 987,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0
},
"difficulty": "0x400",
"gasLimit": "0x8000000",
"alloc": {}
}
不然会觉得有点啰嗦,不够简洁。
新版本geth,出于安全考虑,默认禁止了HTTP通道解锁账户
相关issue:ethereum/go-ethereum#17037
第5章中的“转账与收款”
需要以下面的命令来启动节点,才能使用personal.unlockAccount()
geth --datadir ./db/ --http --http.addr=127.0.0.1 --http.port 8545 --http.corsdomain "*"
--http.api "eth,net,web3,personal,admin,shh,txpool,debug,miner"
--nodiscover --maxpeers 30 --networkid 198989 --port 30303
--mine --miner.threads 1
--miner.etherbase "0xb35316db015e203b0fffe4f8fa99201f26bb0edc"
--allow-insecure-unlock
如果没有加参数 --allow-insecure-unlock,则会报错
GoError: Error: account unlock with HTTP access is forbidden at web3.js:6365:9(45)
启动 Geth 节点下,
cd ether-test geth --datadir ./db/ --rpc --rpcaddr=127.0.0.1 --rpcport 8545 --rpccorsdomain "*" \ --rpcapi "eth,net,web3,personal,admin,shh,txpool,debug,miner" \ --nodiscover --maxpeers 30 --networkid 198989 --port 30303 \ --mine --minerthreads 1 \ --etherbase "0x7df9a875a174b3bc565e6424a0050ebc1b2d1d82" \ console
--minerthreads 和 --etherbase 在 Geth/v1.10.8-stable/darwin-amd64/go1.16.6 中应更新为 --miner.threads 和 --miner.etherbase
另外,--rpcapi "eth,net,web3,personal,admin,shh,txpool,debug,miner" 中的 shh 模块已在 geth 中被删除(因此会提示 Unavailable modules in HTTP API list unavailable=[shh])
请问下,这个重排是怎么实现的
出处:
var output = {"contracts":{"Vault.sol:Vault":{"abi":"[{\"constant\":false,\"inputs\":[{\"name\":\"data\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]","bin":"608060405234801561001057600080fd5b5060bf8061001f6000396000f30060806040526004361060485763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166360fe47b18114604d5780636d4ce63c146064575b600080fd5b348015605857600080fd5b5060626004356088565b005b348015606f57600080fd5b506076608d565b60408051918252519081900360200190f35b600055565b600054905600a165627a7a723058203269ba0a634bf05e2a15966872aaa719b6d147aaa419d656374ad860104e6ef40029"}},"version":"0.4.24+commit.e67f0147.Darwin.appleclang"}
目标:实现教材中那样对编译结果的重排
实际结果: Command 'var' not found, but there are 18 similar ones.
具体操作: 在系统终端直接输入 var output = {"contracts":{"Vault.sol:Vault":{"abi":"[{\"constant\":false,\"inputs\":[{\"name\":\"data\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]","bin":"608060405234801561001057600080fd5b5060bf8061001f6000396000f30060806040526004361060485763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166360fe47b18114604d5780636d4ce63c146064575b600080fd5b348015605857600080fd5b5060626004356088565b005b348015606f57600080fd5b506076608d565b60408051918252519081900360200190f35b600055565b600054905600a165627a7a723058203269ba0a634bf05e2a15966872aaa719b6d147aaa419d656374ad860104e6ef40029"}},"version":"0.4.24+commit.e67f0147.Darwin.appleclang"}
系统: ubuntu 18.04
solc version : version: 0.8.16+commit.07a7930e.Linux.g++
一路都按照说明进行配置,但是开始命令行之后就始终卡在looking for peer上面。
根据说明,该私链上应该只有我们一个节点,如何能解决这个问题呢?
也试过改为#16中的指令,结果没有改善。
端口已经通过firewall-cmd打开了8545/tcp, 8545/udp, 30303/tcp, 30303/udp, 30304/udp
该书原文:
transactions 交易列表: 所有入选该区块的交易的哈希值列表,每个哈希是一个 32字节 的数据。根据哈希值,可以用客户端在以太坊节点上唯一查询该笔交易
但是根据github的geth源码:
https://github.com/ethereum/go-ethereum/blob/master/core/types/block.go#L168
type Block struct { header *Header uncles []*Header transactions Transactions ...
以及
https://github.com/ethereum/go-ethereum/blob/6c3513c0775e1e1e69a7c9e5c86255804fa3fb36/core/types/transaction.go#L51
`type Transaction struct {
inner TxData // Consensus contents of a transaction
time time.Time // Time first seen locally (spam avoidance)
// caches
hash atomic.Value
size atomic.Value
from atomic.Value
}
type TxData interface {
txType() byte // returns the type ID
copy() TxData // creates a deep copy and initializes all fields
chainID() *big.Int
accessList() AccessList
data() []byte
gas() uint64
gasPrice() *big.Int
gasTipCap() *big.Int
gasFeeCap() *big.Int
value() *big.Int
nonce() uint64
to() *common.Address
rawSignatureValues() (v, r, s *big.Int)
setSignatureValues(chainID, v, r, s *big.Int)
}`
可以看出,这里的区块体中装载的是交易本身(即包含了to,from,data等信息)
另外根据以太坊黄皮书, “一系列的交易 BT” ,也指的是字节序列的交易。
solc 版本 : 0.8.16+commit.07a7930e.Linux.g++
Vault.sol 中的版本也已经改成了 0.8.16
编译命令:solc --optimize --combined-json abi,bin,interface Vault.sol
报错内容:Invalid option to --combined-json: interface
自己的解决办法:删除编译命令中的 interface 选项
得到的结果:
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> vault.sol
{"contracts":{"vault.sol:Vault":{"abi":[{"inputs":[],"name":"get","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"data","type":"uint256"}],"name":"set","outputs":[],"stateMutability":"nonpayable","type":"function"}],"bin":"6080604052348015600f57600080fd5b5060ac8061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806360fe47b11460375780636d4ce63c146049575b600080fd5b60476042366004605e565b600055565b005b60005460405190815260200160405180910390f35b600060208284031215606f57600080fd5b503591905056fea2646970667358221220b31a34ecbff3669e6d04f07befff711201739a9b23791901eb9788f4f400ddcd64736f6c63430008100033"}},"version":"0.8.16+commit.07a7930e.Linux.g++"}
我的问题: 为什么会报错说 Invalid option to --combined-json: interface
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.