According to this answer the POW increases with the number of tx in a bundle. How is this accomplished? I thought the bundle-hash is calculated from all tx and then hashed with the nonce as part of the POW. So only the nonce has to change, which would be independent from the number of tx. What am I missing?
2 Answers
The bundle hash is calculated from the "essence" parts (address, (obsolete)tag, timestamp, value, bundle index) of all transactions.
Then the bundle hash is inserted into all transactions of the bundle.
For all transactions that have a negative value, i. e. they spend IOTA, a signature of the bundle hash is added to the transaction, too.
Then, starting from the "last" transaction of the bundle, tips are selected and added into the transaction.
Now that the transaction is almost finished (everything except the nonce), some PoW is performed, i. e. it is tried to find a nonce so that the transaction hash ends with at least 14 (=Min Weight Magnitude) zero trits. You can also see that when looking at the tryte-encoded transaction hashes - they have nines at the end (unlike addresses or bundle hashes who only very rarely have this).
When the PoW of the last transaction is finished, its hash is added as trunk to the next transaction, and PoW is performed for this transaction as well.
As a consequence:
You need to perform PoW individually for every transaction you attach to the tangle. When reattaching a bundle (change the selected tips), you have to compute PoW for all transactions again. When you promote a bundle, you only have to calculate PoW for one transaction (the zero-value transaction you use to promote your bundle)
-
Can you amend this awesome and detailed step-by-step explanation with a clarification at which point the transaction hash per transaction is calculated and inserted?– ralfCommented Feb 17, 2018 at 17:55
-
@ralf The transaction hash is never inserted into the transaction itself, it is only referenced by other transactions that approve it (as trunk or branch transaction hash). Every node will compute the transaction hash individually when it sees the transaction the first time.– mihi ♦Commented Feb 17, 2018 at 20:44
Nonces are being added to transactions, not to bundles. So for each transaction in the bundle the user have to do a small Proof-of-Work: to find such nonce that will result in the hash of the transaction with a certain number of trailing zero-trits.
So the POW required for a bundle increases linearly with the number of transactions in that bundle.
-
Oh yea, of course. What’s used as input to calculate the POW? Nonce + Tx-Hash? Commented Jan 28, 2018 at 11:31
-
@Akkumulator: The tx hash (which includes the nonce in the hashing material) has to end with enough zero trits. So POW uses the rest of the transaction as input and modifies the nonce and re-hashes the transaction until the transaction hash fulfills this property.– mihi ♦Commented Jan 28, 2018 at 12:30
-
@mihi ah ok thanks, got confused there. I assume 12 of those zeros are encoded in the last 4
9999
of the tx hash. Commented Jan 28, 2018 at 13:21