Skip to content

Latest commit

 

History

History
87 lines (67 loc) · 5.54 KB

2018-10-16:區塊鏈隨讀.md

File metadata and controls

87 lines (67 loc) · 5.54 KB

區塊鏈隨便看

亂看,不懂就查。算是隨便撈點問題看看的一篇。有些提問已經很舊了,所以答案到現在可能不準了,要多想想看。

Hyperledger Validating Peers (VPs) 不挖礦, peers 之間不 share blocks。它的機制為:

  1. 一筆交易送給一個 trusted VP
  2. 這一個 trusted VP 將這筆交易廣播給 所有 VP
  3. 所有 VP 依序執行這些 transactions 達到共識(採用 PBFT algorithm 拜占庭容錯演算法)
  4. 所有 VP 會自己執行 transactions �、根據完整的次序並且建立已執行交易的 block (主要為計算 hase) 。
  5. 所有的 blocks 會一樣,因為交易執行是(應該要是)確定性的(deterministic),block 裡面的交易數量也是固定的。
  • PBFT 概念的做法則是:全網會先挑選出一個領導者,每一次要產生 Block 時,由他發號施令,然而其他節點仍然會驗證該領導者所發號的施令合不合邏輯,若不合理就趕他下台。藉由換領導者的方式來保障不會被惡意節點攻擊,該演算法的保障是只要少於 1/3 個節點是惡意的就不會有問題。

Ethereum 跟 Hyperledger 兩者情況不一樣。Ethereum 是條公鏈,它的運作是種可預期的方式。跟比特鏈相似。 Hyperledger 就不同,它像個分散式帳本的保護傘。 Hyperledger 架構目標最重要的就是提供一個有彈性的架構。這樣能讓人建立一個任意類型的 ledger-backed 的系統。想像一個 比特幣保護傘,可以產生替代貨幣,另外可�選擇要有哪些特性在,例如共識機制、區塊鏈儲存、節點 composition 等等。

回到問題

  1. Where is the contract stored?
  • Ethereum 有智能合約在鏈上,就像 code 被編譯成 byte code 包在交易裡面一起送到 blockchain 上。
  • Hyperledger 理論上沒有 contract,可能為在帳本上,也可能不在。拿 Fabric 舉例,Fabric 的 code 是被部署在一個 Docker container sandboxed 中,讓人可以用交易跟它互動。
  1. How other participants such as customs and importer can access this contract?
  • Ethereum 的 code 是 公開的,可被讀取、查看,也就是說,你需要利用某些檢查,限定某些人才能跟 contract 互動。一種方式是確認 交易的 sender,只允許特定的人。這就像傳統的系統一樣,需要權限才能做某些存取。
  • Hyperledger 在 Fabric 也有 Certificate Authority 來分發權限使有權存取系統的不同部分。例如搬運(transport)、簽署(endorsement)或交易(transactions)。
  1. Can we activate participant level access to the contract on the blockchain?
  • 可以、設計 smart contract 控制存取權限、Fabric 中可以用部分的 ledger 用來作存取控管的

For reference, 12 confirmations is approximately 3 minutes. Vitalik Buterin 有回應此問題 有幾種 modules 來追蹤交易的狀態

  • unconfirmed
  • X confirmations
  • conflicting transaction exists and is being confirmed
  • fully confirmed
  • definitely failed 並且顯示這些 info 到 UI 上(with color-coding)。 你應該只顯示 已經無法逆(irreversible)的資料(在 12 confirmations)到 UI 上。

Solidity 還沒支援 array 結構。有在開發,但現在還沒辦法。需要一次取多個元素,然後解構。

As you mentioned, this is not yet supported in Solidity. The powers that be are planning on changing it so you can, but for now, you have to retrieve the number of elements and then retrieve the decomposed struct as a tuple.

function getBidCount(bytes32 name) public constant returns (uint) {
    return highestBidder[name].length;
}

function getBid(bytes32 name, uint index) public constant returns (address, uint, bytes32) {
    Bid storage bid = highestBidder[name][index];

    return (bid.bidOwner, bid.bidAmount, bid.nameEntity);
}

Local storage variables 為 state variablespointers (which are always in storage). From the Solidity docs:

local variable xunit[] 的儲存型態,但儲存並不是動態分配,使用之前,它需要從 state variable 來指派(assigned)。所以 x 中沒有 space,相反的它在 storage 的功用就只是 pre-existing variable 的 alias。

中本聰 白皮書 初衷

ERC20

ERC721

https://blockcast.it/2018/04/07/erc721-erc20-ethereum-token-standard/

ERC875

https://blockcast.it/2018/07/15/the-non-fungible-token-and-erc-875/ http://8btc.com/article-4614-1.html https://juejin.im/post/5b5fc4c56fb9a04fe548ff45 https://www.jianshu.com/p/fc4dbe1fbf2c

open zepelin

0x

我對 dapp 的概念還是模糊不清

token 到底存在哪邊

contract address 存在哪邊?

挖礦的人有哪些獎勵

挖出的逛 需要哪些人 or 多少人驗證?

交易需要哪些人 or 多少人驗證?

ERC20 這存在哪裡?我要怎麼辨識?

ERC223

ERC721

EIP721 簽章