零知识证明比较与分析
- Zero-Knowledge Proofs ==> https://zkp.science/
- https://github.com/matter-labs/awesome-zero-knowledge-proofs
在burrow项目中,/consensus/abci/app.go:
1 | func (app *App) CheckTx(req types.RequestCheckTx) types.ResponseCheckTx { |
此处的 ExecuteTx 位于 /execution/execution.go :
1 | // If the tx is invalid, an error will be returned. |
此处 txExecutor.Execute(txe, txe.Envelope.Tx.Payload) 因 txExecutor 类型的不同,分别对应至 /txs/payload/payload.go 中的 Type ,如下:
1 | // Account transactions |
根据 Type 不同,在如下 contexts 对应的 Context 的 Execute 方法则会不同,分别对应为如下代码文件中的 Execute 方法:
1 | ├── burrow |
例如,在执行发送 TypeCall 类型的交易时, txExecutor.Execute(txe, txe.Envelope.Tx.Payload) 对应的具体逻辑为 /execution/contexts/call_context.go 中的 Execute 方法:
1 | func (ctx *CallContext) Execute(txe *exec.TxExecution, p payload.Payload) error { |
在执行 ExecuteTx(logHeader, app.committer, app.txDecoder, req.GetTx()) 中,executor execution.Executor 被指定为 app.committer , 与 CheckTX 执行同样的 Execute 逻辑
具体执行逻辑为 /execution/execution.go 中的 func (exe *executor) Commit(header *abciTypes.Header) (stateHash []byte, err error)
抽出Burrow内置的solidity接口合约。
1 | ➜ script ./burrow natives |
1 | ➜ script ./burrow dump local backup_dump |
从backup文件恢复区块链
文档链接=>https://hyperledger.github.io/burrow/
github链接=>https://github.com/hyperledger/burrow/
接前文《体验Hyperledger-Burrow-1》,启动4个节点如下:
1 | ➜ script ps aux | grep burrow |
1 | ./burrow spec -v1 | ./burrow configure -s- > burrow_add.toml |
运行完成后,增加公私钥文档如下:
1 | ➜ data pwd |
修改burrow_add.toml配置:
1.删除GenesisDoc的内容,因为genesis.json中已经包含了节点们的GenesisDoc;
2.增加PersistentPeers,PersistentPeers在burrow000.toml中可以找到;
3关闭grpc端口,关闭rpc.info等,否则会跟已有的4个节点端口冲突
制作增加validator Tx 交易的文件:
1 | jobs: |
其中4F3530024CF75A7AFC4D168CF2975C285D03CEBB1CBE82E21AD9C76531A63128 是新节点的publickey。
执行交易命令(DCF0F3BD45EA59B2D471729EC22838DF7B119012 是增加节点前已经启动的4个节点中的Full Account节点。),即在已经启动的节点上执行本交易:
1 | ./burrow deploy -c 127.0.0.1:10997 --mempool-signing=true --address=DCF0F3BD45EA59B2D471729EC22838DF7B119012 deploy.yaml |
注意:新创建的validator没有余额。
1 | ./burrow start --config=burrow_add.toml --genesis=genesis.json --address=5ECA9967F5D363F21C4606CC971710200A64C5BC |
5ECA9967F5D363F21C4606CC971710200A64C5BC 是被增加节点的地址(address)。
1 | ➜ script ps aux | grep burrow |
ed25519是tendermint选择的加密曲线,secp256k1是ethereum选择的加密曲线。
两者都可以在./burrow keys list 中看到账户地址和名称。在web3.getAccounts中只能够看到secp256k1曲线下生成的账户地址,metamask和remix也是如此。
burrow keys gen -n -t secp256k1 --name zhuang 如果不指定 -n 的话,需要输入密码。
创建转账交易 deploy_sendToken.yaml
1 | jobs: |
发起
1 | ➜ script ./burrow keys gen -n -t secp256k1 --name zhuang1 |
文档链接=>https://hyperledger.github.io/burrow/
github链接=>https://github.com/hyperledger/burrow/
Burrow是一个权限控制较为严格、以太坊EVM和WASM虚拟机支持、运行于Tendermint共识之上的区块链客户端。其主要由Monax贡献,并由Monax 和英特尔赞助。
其强调的设计理念包括:
Burrow应用于多个区块链生产项目。
从https://github.com/hyperledger/burrow/下载可执行文件,本文以 ubuntu 环境为例。
1 | ./burrow spec -f2 -p2 | ./burrow configure --curve-type secp256k1 -s- --pool --separate-genesis-doc=genesis.json |
./burrow spec 建立一个GenesisSpec作为GenesisDoc和configure命令的模板,f2是指2个full-accounts,p2是指2个participant-accounts。
--curve-type secp256k1 是指定加密曲线的类型。
./burrow configure -s- 通过使用GenesisDoc或GenesisSpec,创建密钥并创建配置文档。--pool 为名为burrowNNN.toml的所有共识节点(validators)编写配置文件。--separate-genesis-doc 将genesis文档投送至 JSON或者TOML文件。
validator-accounts 共识的参与者,需要抵押一部分资金
root-accounts 根账户
developer-accounts 开发者,功能很多和全节点很像
participant-accounts 参与者
full-accounts 全功能
1 | ➜ script ./burrow start --config=burrow000.toml & |
1 |
|