BCT
BCT
&
Development Tools Frameworks
Solidity language
• Solidity is a domain-specific language of choice
for programming contracts in Ethereum.
Example:
Example :
Note: These types can also be declared with the constant keyword
Address
• This data type holds a 160-bit long (20 byte) value.
• This type has several members that can be used to interact with and query the contracts. Example :
static (fixed size) array
• Balance: The balance member returns the balance of the address in Wei.
• Send: This member is used to send an amount of ether to an address (Ethereum's 160-
bit address) and returns true or false depending on the result of the transaction
dynamically sized array
Example
Get length of trades
• Call functions: The and calls are provided in order to
interact with functions that do not have ABI. These functions should be used with caution
as they are not safe to use due to the impact on type safety and security of the contracts.
• Array value types (fixed size and dynamically sized byte arrays): Solidity has fixed
size and dynamically sized byte arrays. Fixed size keywords range from to
, whereas dynamically sized keywords include and . The
keyword is used for raw byte data and is used for strings encoded in UTF-8. As
these arrays are returned by the value, calling them will incur gas cost. is a
member of array value types and returns the length of the byte array.
Literals
• These used to represent a fixed value.
Integer literals :
• Integer literals are a sequence of decimal numbers in the
range of 0-9.
Example
String literals :
• String literals specify a set of characters written with
double or single quotes.
Example
Hexadecimal literals :
• Hexadecimal literals are prefixed with the keyword hex
and specified within double or single quotation marks.
Example
Enums
• This allows the creation of user-defined types.
Example
• As copying between memory and storage can be quite expensive, specifying a location
can be helpful to control the gas expenditure at times. Calldata is another memory
location that is used to store function arguments.
// This function is used to compute the Keccak-256 hash of the argument provided
to the function:
// This function returns the associated address of the public key from the elliptic curve
signature:
Control
structures
Events
Relevant tools or
Blockchain projects modules that support
these blockchains
• As there have been many contributions made to the Hyperledger project by the
community, Hyperledger blockchain platform is evolving into a protocol for
business transactions. Hyperledger is also evolving into a specification that can be
used as a reference to build blockchain platforms as compared to earlier
blockchain solutions that address only a specific type of industry or requirement.
• Ledger and transactions, which consists of the distributed ledger, ordering service,
network protocols, and endorsement and validation services. This ledger is
updateable only via consensus among the participants of the blockchain network.
• Smart contracts layer, which provides chaincode services in Hyperledger and makes
use of secure container technology to host smart contracts. We will see all these in
more detail in the Hyperledger Fabric section shortly.
Rich
data The modular
queries approach
Privacy and
Portability
confidentiality
REQUIREMENTS
AND
DESIGN GOALS
OF
Interoperability HYPERLEDGER FABRIC Scalability
Deterministic
Auditability
transactions
Identity
Fabric
• Membership services make use of a certificate authority ( Fabric CA ) in order to support identity
management and authorization operations.
• Fabric CA issues enrollment certificates (E-Certs), which are produced by enrollment certificate
authority (E-CA)
Blockchain services
Consensus services:
• A consensus service is responsible for providing the interface to the consensus mechanism.
• Consensus in Hyperledger V1 is implemented as a peer called orderer, which is responsible for
ordering the transactions in sequence into a block. Orderer does not hold smart contracts or
ledgers.
• There are two types of ordering services available in Hyperledger Fabric:
• SOLO: This is a basic ordering service intended to be used for development and testing
purposes.
• Kafka: This is an implementation of Apache Kafka, which provides ordering service. It should
be noted that currently Kafka only provides crash fault tolerance but does not provide
byzantine fault tolerance. This is acceptable in a permissioned network where chances of
malicious actors are almost none.
Distributed ledger
• Blockchain and world state are two main elements of the distributed ledger. Blockchain is simply a
cryptographically linked list of blocks and world state is a key-value database.
• These transactions contain chaincode, which runs transactions that can result in updating the world
state. Each node saves the world state on disk in LevelDB or CouchDB depending on the
implementation.
• The P2P protocol in the Hyperledger Fabric is built using google RPC (gRPC). It uses protocol buffers to
define the structure of the messages.
• There are four main types of messages in Hyperledger Fabric:
• Discovery
• Transaction
• Synchronization
• Consensus
• Discovery messages are exchanged between nodes when starting up in order to discover other
peers on the network.
• Transaction messages are used to deploy, invoke, and query transactions.
• Consensus messages are exchanged during consensus.
• Synchronization messages are passed between nodes to synchronize and keep the blockchain
updated on all nodes.
Ledger storage
• In order to save the state of the ledger, by default, LevelDB is used which is available at each peer.
An alternative is to use CouchDB which provides the ability to run rich queries.
Chaincode services
• Peers participate in maintaining the state of the distributed ledger. They also hold a local copy of
the distributed ledger.
• Peers communicate via gossip protocol.
• There are three types of peers in the Hyperledger Fabric network:
• Endorsing peers or endorsers which simulate the transaction execution and generate a read-
write set. Read is a simulation of transaction's reading of data from the ledger and write is the
set of updates that would be made to the ledger if and when the transaction is executed and
committed to the ledger. Endorses execute and endorse transactions. It should be noted that
an endorser is also a committer too. Endorsement policies are implemented with chaincode
and specify the rules for transaction endorsement.
• Committing peers or committers which receives transaction endorsed by endorsers, verify
them and then update the ledger with the read-write set. A committer verifies the read-write
set generated by the endorsers along with transaction validation.
• Submitters is the third type of peers which has not been implemented yet. It is on the
development roadmap and will be implemented
Orderer nodes
• Ordering nodes receive transactions from endorsers along with read-write sets, arrange them in a
sequence, and send those to committing peers. Committing peers then perform validation and committing
to the ledger.
• Clients are software that makes use of APIs to interact with the Hyperledger Fabric and propose
transactions.
Channels
• Channels allow the flow of confidential transactions between different parties on the network. They
allow using the same blockchain network but with separate blockchains.
• Channels allow only members of the channel to view the transaction related to them, all other
members of the network will not be able to view the transactions.
World state database
• World state reflects all committed transaction on the blockchain. This is basically a key-value store
which is updated as a result of transactions and chaincode execution. For this purpose, either LevelDB
or CouchDB is used.
• LevelDB is a key-value store whereas CouchDB stores data as JSON objects which allows rich queries to
run against the database.
Transactions
• Transaction messages can be divided into two types: deployment transactions and invocation
transactions. The former is used to deploy new chaincode to the ledger, and the latter is used to call
functions from the smart contract. Transactions can be either public or confidential.
• Public transactions are open and available to all participants whilst confidential transactions are visible
only in a channel open to its participants.
Membership Service Provider (MSP)
• MSP is a modular component that is used to manage identities on the blockchain network. This
provider is used to authenticate clients who want to join the blockchain network.
Smart contracts
• In Hyperledger Fabric same concept of smart contracts is implemented but they are called chain
code instead of smart contracts.
• They contain conditions and parameters to execute transactions and update the ledger.
Chaincode is usually written in Golang
• Even though various use cases and proof of concept systems have been developed and the
technology works well for many of the scenarios, there still is a need to address some fundamental
limitations that are present in blockchains in order to make this technology more adaptable.
• At the top of the list of these issues comes scalability and then privacy.
• Both of these are important limitations to address, especially as blockchains are envisioned to be
used in privacy-demanding industries too. There are specific requirements around confidentiality of
transactions in finance, law, and health.
• scalability is generally a concern where blockchains do not meet the adequate performance levels
expected by the users.
Approach toward tackling the scalability issue:
• Block size increase
• This is the most debated proposal for increasing blockchain performance (transaction processing
throughput).
• Currently, Bitcoin can process only about three to seven transactions per second, which is a
major inhibiting factor in adapting the Bitcoin blockchain for processing microtransactions.
• Block size in Bitcoin is hardcoded to be 1 MB, but if the block size is increased, it can hold more
transactions and can result in faster confirmation time. There are several Bitcoin Improvement
Proposals (BIPs) made in favor of block size increase. These include BIP 100, BIP 101, BIP 102, BIP
103, and BIP 109.
• In Ethereum, the block size is not limited by hardcoding; instead, it is controlled by a gas limit. In
theory, there is no limit on the size of a block in Ethereum because it's dependent on the amount
of gas, which can increase over time
• a blockchain can be divided into various abstract layers called planes. Each plane is responsible for
performing specific functions. These include the network plane, consensus plane, storage plane, view
plane, and side plane.
• A key function of the network plane is transaction
propagation.
• This plane underutilizes the network bandwidth due
• This plane represents the idea of off-chain to the way transaction validation is performed by a
transactions whereby the concept of Network node before propagation and duplication of
payment or transaction channels is used to Plane transaction propagation, first in the transaction
offload the processing of transactions broadcast phase, and then after mining in a block.
between participants but is still backed by
the main Bitcoin blockchain.
• This layer is responsible for mining and
Consensus achieving consensus.
Side Plane • Bottlenecks in this layer revolve around
Plane
limitations in PoW algorithms whereby
Blockchain increasing consensus speed and
bandwidth results in compromising the
security of the network due to an
increase in the number of forks.
• The key idea is based on the fact that there is no need to transfer all transactions between nodes;
instead, only those that are not already available in the transaction pool of the syncing node are
transferred.
• This allows quicker transaction pool synchronization between nodes, thus increasing the overall
scalability and speed of the Bitcoin
Sharding
• The key idea behind sharding is to split up the tasks into multiple chunks that are then processed by
multiple nodes. This results in improved throughput and reduced storage requirements.
• In blockchains, a similar scheme is employed whereby the state of the network is partitioned into
multiple shards. The state usually includes balances, code, nonce, and storage. Shards are loosely
coupled partitions of a blockchain that run on the same network. There are a few challenges related to
inter-shard communication and consensus on the history of each shard.
State channels
• The basic idea is to use side channels for state updating and processing
transactions off the main chain; once the state is finalized, it is written back
to the main chain, thus offloading the time-consuming operations from the
main blockchain.
• State channels work by performing the following three steps:
1. First, a part of the blockchain state is locked under a smart
contract, ensuring the agreement and business logic between
participants.
2. Now off-chain transaction processing and interaction is started
between the participants that update the state only between
themselves for now. In this step, almost any number of
transactions can be performed without requiring the
blockchain and this is what makes the process fast and a best
candidate for solving blockchain scalability issues. However, it
could be argued that this is not a real on-blockchain solution
such as, for example, sharding, but the end result is a faster,
lighter, and robust network which can prove very useful in
micropayment networks, IoT networks, and many other
applications.
3. Once the final state is achieved, the state channel is closed and
the final state is written back to the main blockchain. At this
stage, the locked part of the blockchain is also unlocked.
• Private blockchain
• Proof of Stake
• Sidechains
• Subchains
• Tree chains
• Block propagation
Plasma
• This proposal describes the idea of running smart contracts on root blockchain (Ethereum MainNet)
and have child blockchains that perform high number of transactions to feedback small amounts of
commitments to the parent chain.
• In this scheme, blockchains are arranged in a tree hierarchy with mining performed only on the root
(main) blockchain which feeds the proofs of security down to child chains. This is also called a Layer-
2 system, like state channels also operate on Layer 2, and not on the main chain.
Privacy
• Privacy of transactions is a much-desired property of blockchains.
• However, due to its very nature, especially in public blockchains, everything is transparent, thus
inhibiting its usage in various industries where privacy is of paramount importance, such as
finance, health, and many others.
• There are different proposals made to address the privacy issue and some progress has already
been made. Several techniques, such as Indistinguishability Obfuscation (IO), usage of
homomorphic encryption, ZKPs, and ring signatures
Indistinguishability Obfuscation
• This cryptographic technique may serve as a silver bullet to all privacy and confidentiality issues
in blockchains but the technology is not yet ready for production deployments.
• IO allows for code obfuscation, which is a very ripe research topic in cryptography and, if applied
to blockchains, can serve as an unbreakable obfuscation mechanism that will turn smart
contracts into a black box.
Homomorphic encryption
State channels
• Privacy using state channels is also possible, simply due to the fact that all transactions
are run off-chain and the main blockchain does not see the transaction at all except for
the final state output, thus ensuring privacy and confidentiality.
Secure multiparty computation
• The concept of secure multiparty computation is not new and is based on the notion that
data is split into multiple partitions between participating parties under a secret sharing
mechanism which then does the actual processing on the data without the need of the
reconstructing data on a single machine. The output produced after processing is also shared
between the parties.
Confidential transactions
Security
• Even though blockchains are generally secure and make use of asymmetric and symmetric
cryptography as required throughout the blockchain network, there still are few caveats that
can result in compromising the security of the blockchain.
• There are a few examples of transaction malleability, eclipse attacks, and the possibility of
double spending in bitcoin that, in certain scenarios, have been shown to work by various
researchers. Transaction malleability opens up the possibility of double withdrawal or deposit
by allowing a hacker to change a transaction's unique ID before the Bitcoin network can
confirm it, resulting in a scenario where it would seem that transactions did not occur.
• BIP 62 is one of the proposals along with SegWit that have suggested solutions to solve this
issue.
THANK YOU!