baking, delegating, rewards, deposit, seed generation, roll distribution, protocol updates, smart contract and more !
Blog post here
First thing first a little bit of history
Fundraiser collected 65,681 bitcoins and 361,122 ethers. Most of the contributions happened in the first few days. 62.5% of the contributions were in bitcoin, 37.5% in ether.
A that time it represented more than 230 millions dollars.
The total initial supply was 763,306,929.69 tokens.
Tezos aims at being a digital commonwealth, the best smart contract platform and ultimately useful for people.
How does Tezos compare with other smart contract blockchains ?
Tezos beginner FAQ
What is the name of Tezos cryptocurrency ? tezzies. the symbol is ꜩ or XTZ
- How mining a block is called ? baking
- How many tezzies are necessary to bake ? 10 000 tezzies also known as one roll
- How is selected the dynamic set of bakers ? randomly
- Can you benefit from baking rewards if you are not a baker ? Yes You can delegate your baking rights to a baker without transferring the ownership of your tezzies
implicit? originated? which one for baking? which one for delegating?
In Tezos there are two kinds of accounts: implicit and originated.
The implicit accounts are the TZ and to create them if suffices to have a pair of keys and to transfer some funds to the public key hash.
Originated accounts have addresses KT and are created through an origination operation. It can contain code.
What can i do with these accounts?
let’s summarize the account types and their relations to baking
- To bake you will register an implicit account as a baker (aka a delegate).
- To delegate your baking rights, you will create an originated account from an implicit account and set the delegate
What the Block man ?
How blocks are created? what are the rewards? what is at stake?
In a proof of work consensus, miners invest a lot into efficient mining rig to compute a nonce to validate a block they then hope that their block will propagate faster than an eventual competing block at the same level.
In a proof of stake consensus, miners put their cryptocurrency at stake to validate a block. Then the consensus will elect them, or in the case of Tezos randomly select them, to mine a block. If they misbehave their deposit is slashed.
In Tezos we randomly select for each block one baker and also surrogates in case the baker can’t bake. Surrogates are ordered by priority.
We also randomly select for each block 32 endorsers. Endorsement are made by bakers. Endorsers don’t have surrogates. If endorsement isn’t made, the slot stays empty. Each endorser verifies the last block that was baked. Endorsement will contribute to the weight (aka fitness) of the block.
What are the rewards for these operations ?
for each block baked the baker will receive 16ꜩ and 2ꜩ for each endorsement.
Wait…this is a proof of stake so tezzies should be put at stake for these operations right ?
Absolutely for each block baked the baker will have 512ꜩ held into deposit and each endorsers will have 64ꜩ held into deposit.
When can I lose my deposit ?
Your deposit will be slashed if :
- You bake two blocks at the same height
- You endorse twice at the same position
What happen if there is not enough tezzies for the deposit?
If a baker doesn’t have enough for the deposit then he simply can’t bake or endorse. The next priority baker will then take over. In the case of an endorsement the slot stays empty.
Can this happen ?
Yes! If a baker has a lot of tezzies delegated to him but not much on his account. As it is random, statistically he has more chances to be selected for baking thus he would need a lot of tezzies for deposit.
It is known as over delegation ! It slows down the network and reduce the rewards. A baker should own over 8.25% of the amount of token delegated to them in order to not miss out on creating any block.
What are cycles ?
How can we calculate inflation?
Blocks are grouped into cycles of 4,096 blocks. Since blocks are at least one minute apart, this means a cycle lasts at least 2 days, 20 hours, and 16 minutes. That also means that only 60*24 = 1440 blocks can be bake per day. We can then calculate the inflation in Tezos
(1440 blocks * 365 days) * (16 ꜩ + 32 * 2 ꜩ) = 42 048 000 ꜩ
That is the max amount of new tezzies each year which corresponds to a 5.36% Annual Non-Dilutionary Inflation (based on a total supply of 784,326,217 number grabbed from tzscan )
As it is an inflationary cryptocurrency, this means that total supply of tokens will increase every year. As a token holder if you will be diluted if you don’t get a share of this inflation.
What are roll snapshots ?
How baking right are drawn? What if I delegate?
Roll snapshots allow to froze who owns what at one particular point in time. Here it is a certain block height (aka level). Based on that picture we can tell how many rolls an account has and we can draw the baking right. For reminder one roll = 10 000 ꜩ. Rolls help keep track of tezzies owners.
We can think of rolls like lottery tickets and baking right are the prizes ! The more rolls you have better are your chances to bake or endorse a block.
Let’s take an imaginary roll snapshot
This picture will give us the distribution of tezzies (by share of 10 000ꜩ) at the moment of the snapshot. Based on who owns the lottery ticket we will randomly draw, with replacement, the baking rights.
Here are the account that hold the tezzies that correspond to these rolls.
So we understand that the account TZ4 is the owner of rolls number 12 to 19. It also means that he holds 8 rolls = 80 000ꜩ. He also has 8 chances out of 19 to be selected for baking or endorsement.
Now with a random number generator we will draw the baking right for a block and their endorsers based on the snapshot here below.
Block 1 BAKER PRIO 0: Roll number 12
Block 1 BAKER PRIO 1: Roll number 14
Block 1 BAKER PRIO 2: Roll number 1
Block 1 BAKER PRIO 3: Roll number 12
Block 1 ENDORSER 1: Roll number 11
Block 1 ENDORSER 2: Roll number 2
Block 1 ENDORSER 3: Roll number 5
Block 1 ENDORSER 4: Roll number 2
Can you guess who will bake the block 1 at priority 0 ? The drawn roll was the number 12 and it is owned by TZ4. Congrats TZ4 you won the right to bake first the block number 1 !
Can you guess who will be the endorser number 1 for the block 1? The drawn roll was the number 11 and it is owned by KT3 and KT3 delegated to TZ3. So TZ3 will be the endorser at slot 1 for block 1!
Notice that the roll number 2 has been drawn twice.
The awesomeness of distributed randomness
Why a CSPRNG? How can we generate a seed ?
Previously we said that we use a random number generator. To generate random number we need a source of entropy or seed.
How can we generate a random number on a distributed application like a blockchain and be sure that everybody come up with the same randomness ? How can we prevent us from an attacker that will influence the seed to obtain more baking rights ?
To sum it up, some bakers will generate a random number and reveal it later. By combining all these numbers we get a seed. We can then seed a random number generator. Let’s see it on a timeline ..
On cycle n-7 once every 32 blocks will contain a nonce hash. Indeed the corresponding bakers will have to generate a number, hash it and include that hash in the block header. By the end of the cycle we will then have 128 blocks (4096/32) containing a nonce hash. As a result, those 128 bakers will have to reveal their hash in the next cycle (n-6).
On cycle n-6 the bakers of cycle n-7 who have generated a random number will have to send a reveal operation under penalty of forfeiting the rewards and fees. Bakers of cycle n-6 are incentivize to add those revelations operation they will earn an extra 1/8ꜩ. Moreover the revelations are free operations which do not compete with transactions for block space. At the end of cycle n-6 we can generate the seed which is a 256 bit number made by hashing the revelations together.
Once computed, this new seed is stored and used during cycle n.
Here we use the seed with a Cryptographically Secure Pseudo Random Number Generator. Why is it pseudo random ?
Because we need all the nodes to draw baking rights in the same order. It must be deterministic.Indeed if we ask for 100 random numbers all the nodes will come up with the same numbers in the same order
Why not delegating? When will I get my rewards? When will I bake?
Now that we have a seed we can draw one out of the 16 roll snapshots of two cycle before. Inside that roll we will draw all the baking right and endorsers. These right will be used only five cycles after.
When the baking rewards can be used ?
When you will bake or endorse a block the security deposit and the reward associated will automatically be moved to the deposit account. The fund will be held for five full cycle.
Here is a global view illustrating the important milestones, going from the seed generation (at cycle n-7) to the baking rewards ( cycle n+11).
Why would you delegate instead of baking ?
Because you want your share of the baking rewards without :
- transferring ownership of your tezzies
- risking your tezzies in a deposit
- maintaining an active Tezos node
Ok…What’s the catch ?
When delegating you will not :
- Receive the rewards directly. The baker you are delegating to is responsible for sending you your rewards …minus their fees!
- Take part into the built in governance mechanism you are also delegating your voting power
- Be safe against over delegation. Bakers cannot refuse delegators. Be careful not to delegate to an already over-delegated baker.
When would i get my delegating rewards if I delegate right now ?
What are the stages?
Tezos is shipped with an on-chain mechanism for proposing, selecting, testing, and activating protocol upgrades without the need to hard fork.
The protocol dictates all the rules that nodes follow.
We can break the process into four pieces that leave 3 months from proposal to activation.
Failure to proceed restarts the entire amendment process.
This is what is happening since the Tezos genesis block in June.
In the absence of any proposals, a new proposal period has restarted every eight cycles since Block 1.
Nomadic lab is preparing his first Amendment Proposals including (storage improvement, Higher Gas limit, lower roll size etc…)
What languages for Tezos?
The language for smart contract is Michelson. Michelson is a stack-based language. Computation is performed by mutating a sequence of data elements (the stack) according to some sequence of instructions (the program).
Michelson has control flow structures like LOOP or IF. We can perform some cryptographic operations like hashing or checking signatures We can interact with the blockchain by initiating token transfers or creating accounts. Michelson has lot of different operations. Michelson data elements are typed.
The lack of variables and the use of stack-based instructions make michelson hard to write, and harder to read.
The Liquidity language was officially released in February 2018 on the Alphanet network of Tezos from the need for a higher-level language.
Liquidity follows Michelson type-system, but implemented on a subset of the OCaml syntax. It comes with a compiler to Michelson, and a decompiler that can translate Michelson contracts to Liquidity, for auditing purpose.
In the context of hardware and software systems, formal verification is the act of proving or disproving the correctness of intended algorithms underlying a system with respect to a certain formal specification or property.
DPOS — LPOS ?
We saw that DPOS for Tezos in not comparable with DPOS in EOS where there will only be 21 miners (or block producer) and where delegation means voting for block producer to be among the 21.
In EOS being a miner can be a profitable business but like in bitcoin required substantial investment. This few numbers of block producer plus the lack of incentive for voting led to vote buying scandal. The block producers also control other network resources like RAM necessary for dapp (think of it like gas to ethereum) which have also led to other problems.
In Tezos with only 10k ꜩ (probably less in the future), the patience to wait for some cycles like described here above, a regular computer and an internet connection you are guaranteed by the law of statistics that you will be selected to bake or to endorse a block at some point.
The Tezos foundation, arthur breitman or large tezzies holders can’t prevent you from baking and that’s why jacob arluck refers to Tezos consensus as a liquid POS. If you are interested in the number of bakers on the Tezos network you can head over this page.
We covered a lot about baking and delegating. Delegating in Tezos is a way to delegate his baking rights and also his right to vote a protocol upgrade. Of course delegating comes without transferring the ownership of our tezzies.
Baking is a well oiled economical mechanic where rewards and stake encourage good behaviour.
We also understood how in a distributed system like Tezos we manage to generate randomness.
We saw that Tezos’s consensus is not comparable to other DPOS like EOS. Tezos allows (almost) anybody to be a validator and to make his voice heard about protocol improvements. We should see a protocol upgrade quite soon on the mainnet thanks to the proposals of nomadics lab, so, stay tuned ;)
Links and sources
Tezos Block explorer
Tezos stack exchange
Audit your baker with baking bad