Recompensas de horneado como operaciones
2 respuestas
- votos
-
- 2019-04-21
Las recompensas ocurren comoparte delprotocolo ytodoestáencadenado. Perono son una "transacción"en el sentidonormal de lapalabra,ya quenormalmente unatransacción requiere laintervención del usuario. Pero haymovimientosfundamentales defondos del "congelador" a los delegados. Conceptualmente,el congelador retienetemporalmentetodos los vínculos y recompensaspor hornear y respaldar.
Paraencontrarestainformaciónen la cadena,tenemos quemirarel últimobloque del cicloen el queesperaríamos la recompensa.
blockNumForRewards = (rewardedCycleNum + 6) * numOfBlocksInCycle
Porejemplo,parael ciclo 93,las recompensasparael ciclo 93 se desbloqueanen el últimobloque del ciclo 98,por lo quenecesitamosmirarelnúmero debloque
(93 + 6) * 4096 = 405,504
.Después de conocerelnúmero debloque,podemos consultarelbloque connuestronodo obteniendoel hash de unexplorador debloques comotzscan. Eneste caso,
BLdha4dMeWYxYkuP46eCgYwsgBYiKPNFLvgiu5NqgdxPLhkgzUf
esnuestro hash debloque:/chains/main/blocks/BLdha4dMeWYxYkuP46eCgYwsgBYiKPNFLvgiu5NqgdxPLhkgzUf
Obviamente,haymuchainformación aquí,pero centrémonosen la ruta quemaneja los cambios deequilibrio,específicamente
metadata > balance_updates
. Ejemplo:{ "protocol": "PsddFKi32cMJ2qPjf43Qv5GDWLDPZb3T3bF6fLKiF5HtvHNU7aP", "chain_id": "NetXdQprcVkpaWU", "hash": "BLdha4dMeWYxYkuP46eCgYwsgBYiKPNFLvgiu5NqgdxPLhkgzUf", "metadata": { ... "balance_updates": [ // this is what we care about ] } ... }
Estaparte delbloque son las actualizaciones de saldo que retienen lo queelprotocolonecesitapara aplicarindependientemente de lasintervenciones del usuario. Enmuchos de losbloques,estaparte soloincluirá alpanadero debloques actual con sus recompensas ybonosbloqueados. Enel últimobloque del ciclo,
balance_updates
tambiénincluyetodas las recompensas y desbloqueos debonospara cadapanadero queparticipóen el ciclo 93.Detodosmodos,profundicemosen los detalles de unpanaderopara comprendermejor. Porejemplo,hefiltrado lastransacciones de unpanaderoen particular
tz1ivoFE...TD
."balance_updates": [ ... { "kind": "freezer", "category": "deposits", "delegate": "tz1ivoFEvbfbUNav5FwLvmxzMGcNXWxY9qTD", "level": 93, "change": "-10368000000" }, { "kind": "freezer", "category": "fees", "delegate": "tz1ivoFEvbfbUNav5FwLvmxzMGcNXWxY9qTD", "level": 93, "change": "-9362" }, { "kind": "freezer", "category": "rewards", "delegate": "tz1ivoFEvbfbUNav5FwLvmxzMGcNXWxY9qTD", "level": 93, "change": "-321000000" }, { "kind": "contract", "contract": "tz1ivoFEvbfbUNav5FwLvmxzMGcNXWxY9qTD", "change": "10689009362" }, ...
Dentro de lamatriz
balance_updates
,incluirá cada "transacción" que deba ajustarseparatodasestas direcciones,incluidoel "congelador". Cadatransaccióntambién da algunaspistas sobrepara qué sirven.Lo anterioresbastantetípico de lo que veremosporpanadero. Hay 3transacciones relacionadas conel "congelador" y un "contrato". Lastransacciones del "congelador" son diferentes según su
category
(deposits
,fees
yrewards
). Las categorías seexplicanpor símismas. En caso de que sepregunte,los depósitos y las recompensasincluiránbonos y recompensastanto de horneado como deendosos. Tengaen cuenta queesas operaciones del congelador son valoresnegativose implican queestos saldos se restan defreezer
.Latransacción del "contrato"es lo que cambiael saldo delpanaderoen cuestión. Estoesbastante similar a unatransaccióniniciadaporel usuario. Si sumamos los saldos de las 3 categorías de congeladores,se sumarían al saldo de cambioparaelpanadero.
The rewards happen as part of the protocol and it's all on chain. But they are not a "transaction" in the normal sense of the word, as usually a transaction requires some user intervention. But there is fundamental movements of funds from the "freezer" to the delegates. Conceptually, the freezer temporarily holds all the bonds and rewards for baking and endorsing.
To find this information on chain, we have to look at the very last block of the cycle we'd expect the reward.
blockNumForRewards = (rewardedCycleNum + 6) * numOfBlocksInCycle
For example, for cycle 93, the rewards for cycle 93 gets unlocked at the last block of cycle 98, so we need to look at block number
(93 + 6) * 4096 = 405,504
.After we knowing the block number, We can query for the block with our node by getting the hash from a block explorer like tzscan. In this case,
BLdha4dMeWYxYkuP46eCgYwsgBYiKPNFLvgiu5NqgdxPLhkgzUf
is our block hash:/chains/main/blocks/BLdha4dMeWYxYkuP46eCgYwsgBYiKPNFLvgiu5NqgdxPLhkgzUf
Obviously there is a lot of information in here, but let's focus on the path that handles the balance changes, specifically
metadata > balance_updates
. Example:{ "protocol": "PsddFKi32cMJ2qPjf43Qv5GDWLDPZb3T3bF6fLKiF5HtvHNU7aP", "chain_id": "NetXdQprcVkpaWU", "hash": "BLdha4dMeWYxYkuP46eCgYwsgBYiKPNFLvgiu5NqgdxPLhkgzUf", "metadata": { ... "balance_updates": [ // this is what we care about ] } ... }
This portion of the block is the balance updates that retains to what the protocol needs to apply regardless of the user interventions. In a lot of the blocks, this portion will just include the current block baker with its locked rewards and bonds. In the last block of the cycle,
balance_updates
also includes all the rewards and bonds unlocks for every baker that participated in cycle 93.Anyhow, let's dig into the specifics of one baker to understand further. For illustration, I've filtered out transactions for one particular baker
tz1ivoFE...TD
."balance_updates": [ ... { "kind": "freezer", "category": "deposits", "delegate": "tz1ivoFEvbfbUNav5FwLvmxzMGcNXWxY9qTD", "level": 93, "change": "-10368000000" }, { "kind": "freezer", "category": "fees", "delegate": "tz1ivoFEvbfbUNav5FwLvmxzMGcNXWxY9qTD", "level": 93, "change": "-9362" }, { "kind": "freezer", "category": "rewards", "delegate": "tz1ivoFEvbfbUNav5FwLvmxzMGcNXWxY9qTD", "level": 93, "change": "-321000000" }, { "kind": "contract", "contract": "tz1ivoFEvbfbUNav5FwLvmxzMGcNXWxY9qTD", "change": "10689009362" }, ...
Inside of
balance_updates
array, it will include every "transaction" that needs to be adjusted for all these addresses including the "freezer". Each transaction also gives some clues on what they are for.The above is pretty typical what we'll see per baker. There are 3 "freezer" related transactions and one "contract". The "freezer" transaction are different by their
category
(deposits
,fees
andrewards
). The categories are pretty self explanatory. Just in case you are wonder, deposits and rewards will include both baking and endorsements bonds and rewards. Notice that those freezer operations are negative values and they imply that these balances are subtracted fromfreezer
.The "contract" transaction is what changes the balance to the baker in question. This is pretty similar to a user initiated transaction. If we add up the 3 freezer category's balances, they would add up to the change balance for the baker.
-
Estaes la respuesta correcta.Mi respuesta respondió a lapregunta de cómoelpanadero acredita/recompensa a sus delegadores,no cómo se recompensa a unpanadero através delprotocoloen sí.Paraeliminar cualquier confusión,borrémi respuesta.This is the correct answer. My answer answered the question of how baker credit/reward their delegators, not how a baker is rewarded via the protocol itself. To remove any confusion, I've deleted my answer.
- 1
- 2019-04-23
- lostdorje
-
@Frank ¿cómo saber que "tz1ivoFEvbfbUNav5FwLvmxzMGcNXWxY9qTD"eselpanadero? 2. Por qué los depósitos,las comisiones y las recompensas sonnegativos.¿Podrías ayudarme aentender?@Frank how to know that "tz1ivoFEvbfbUNav5FwLvmxzMGcNXWxY9qTD" is the baker ? 2. Why deposits , fees and rewards all are in negative. Could you please help me understand ?
- 0
- 2020-02-23
- user3759202
-
La dirección deesepanaderoes solo unejemplo,peroesta sección soloincluye a lospanaderos.2. "Observe queesas operaciones del congelador son valoresnegativose implican queestos saldos se restan del congelador".El congeladores lo que almacena la cadena,por lo queestamos haciendo un cambio de saldonegativoparael congelador y un cambio de saldopositivo como recompensa.Es suma cero.1.That baker address is just an example, but this section only include bakers. 2. "Notice that those freezer operations are negative values and they imply that these balances are subtracted from freezer." Freezer is what the chain is storing, so we are making a negative balance change for the freezer and a positive balance change as the reward. It's zero sum.
- 0
- 2020-02-23
- Frank
-
@Frank Todavíaestoy confundido con las cosas del congelador.He visto algunasmuestrasen las queel depósitoespositivo y la recompensatambiénespositiva.En quéescenarioestoesposibleparaesteblochHashpodemosencontrarel depósito y la recompensa comopositivos@Frank I am still confused with the freezer stuff. I have seen few samples where deposit is positive and reward is also positive. In which scenario this is possible for this blochHash we can find the deposit and reward as positive
- 0
- 2020-02-24
- user3759202
-
- 2019-04-24
La respuesta de la "versión corta"es queesto se logra através del
consensus
,quees un conceptoextremadamenteimportanteen las cadenas debloques que se utilizanpara las criptomonedas.Desafortunadamente,muchagente simplementeno loentiende realmente;eneste aspecto,eltérmino "consenso" se reduceesencialmente a:(yestaes realmente una descripciónmuy simplificada aquí,sinteneren cuenta las recompensas o depósitos congelados,etc.) El códigoparaelprotocolo Tezos dicta que cuando una cuenta cuece unbloque,el saldo deesa cuenta simplemente aumentaen ꜩ16.Dado quetodosejecutanelmismoprotocolo,todosestán de acuerdoen que cuando una cuenta hornea unbloque,el saldo deesa cuenta aumentaen ꜩ16.Esoes consenso.
The "short version" answer is that this is accomplished through
consensus
, which is an extremely important concept in blockchains that are used for cryptocurrency. Unfortunately many people just dont really understand it; in this aspect essentially the term "consensus" boils down to:(and this really is a very simplified description here, not taking into account freezing rewards or deposits, etc) The code for the Tezos protocol dictates that when an account bakes a block, that account's balance simply goes up by ꜩ16. Since everyone is running the same protocol, everyone agrees that when an account bakes a block, that account's balance goes up by ꜩ16. Thats consensus.
¿Cómo aparecen las recompensas de horneadoen la cadena cuando se le atribuyen alpanadero?¿Es una operación de 'transacción'?¿Cómo hagoparaidentificarlos?