Getting transactions from mempool to block

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












1















I have a question about getting transactions from mempool to be added to block. Imagine the situation where we have 500 transactions in mempool, when we decide that is enough to start adding them to the block? Also what if we sre in the middle of mining (so we have Merkles tree root already) and the new transaction is added to the mempool? The process of our mining in my node is starting again?










share|improve this question


























    1















    I have a question about getting transactions from mempool to be added to block. Imagine the situation where we have 500 transactions in mempool, when we decide that is enough to start adding them to the block? Also what if we sre in the middle of mining (so we have Merkles tree root already) and the new transaction is added to the mempool? The process of our mining in my node is starting again?










    share|improve this question
























      1












      1








      1








      I have a question about getting transactions from mempool to be added to block. Imagine the situation where we have 500 transactions in mempool, when we decide that is enough to start adding them to the block? Also what if we sre in the middle of mining (so we have Merkles tree root already) and the new transaction is added to the mempool? The process of our mining in my node is starting again?










      share|improve this question














      I have a question about getting transactions from mempool to be added to block. Imagine the situation where we have 500 transactions in mempool, when we decide that is enough to start adding them to the block? Also what if we sre in the middle of mining (so we have Merkles tree root already) and the new transaction is added to the mempool? The process of our mining in my node is starting again?







      transactions mempool






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 27 at 11:26









      KonradKonrad

      61




      61




















          3 Answers
          3






          active

          oldest

          votes


















          1














          You can start to work in a block at any moment, you can even mine an empty block. If any new transaction arrives you rebuild the merkle tree and continue.






          share|improve this answer























          • So there is a possibilty to choose how many transactions is ok to start minning? Will the adding new transaction to potential block reset the minning (reset the nonce to zero)?

            – Konrad
            Jan 27 at 11:58


















          1














          While mining is done by specialized hardware, transaction choosing and merkle root calculating is done by the node software. While the specialized hardware is mining, a node may (and will) update its mempool continuously, and will calculate a new merkle root every few seconds. The mining hardware will check for header-template updates often, (and this instantaneous process is done without needing a restart), and will continue mining. The interval of header updates is chosen by the pool, and one of the aims is not to do it too often, or it'll waste the bandwidth






          share|improve this answer























          • I'm not sure that I understand, I thougt that merkle tree is taken to the block, so updating list of transactions will somehow start minning again? (Reset the nonce to zero)

            – Konrad
            Jan 27 at 11:56











          • Yes, they can reset the nonce.

            – MCCCS
            Jan 27 at 12:32











          • So this will not complicate mining? I mean after reseting the nonce we are starting again so we are not as close to winning as we were before reseting the nonce (I guess)

            – Konrad
            Jan 27 at 13:20







          • 1





            No, reseting the nonce with a different block template is not repeating the same POW, as the header hash will be different with the same nonce. (Same nonce, but different merkle-root)

            – James C.
            Jan 27 at 15:15











          • Increase or decreasing a nounce don't make you any closer or far from finding a block. Otherwise you would just go straight to the highest nounce. Any order you try nounces is good.

            – Osias Jota
            Jan 28 at 0:45



















          1














          Producing the optimal block-template to mine is a NP-hard problem.



          The optimal block-template includes the highest sat/byte(or weight) transactions to maximise the miner reward. Assuming this computation and propagation of the perfect block-template took no time, it would make sense to update the block-template for each new transaction accepted to the memo-pool, as this new transaction could potentially increase the block reward. In this hypothetical scenario, the mining hardware is continuously working (hashing) and continuously updating the block header for a better block reward.



          However, since producing the optimal block-template is NP-hard, it takes significant time/cost to compute the optimal block-template from the mempool at any point in time:



          • Knapsack problem - maximise total fee value in block

          • Maximum independent vertex set - ensure no two tx spend the same output.

          Both problems scale exponentially and are expensive. This cost could have been invested in more hash-rate.



          Therefore, there is a trade-off between block optimisation and mining utilization.



          • Continuously optimising for a better block-template represents a cost in itself, which could be invested in more mining hash rate.

          • There exists a financial optimum, where suboptimal blocks-templates are mined, whilst mining equipment is fully utilised.

          • (One extreme could be mining empty blocks, maximising the number of hashes performed, whilst spending zero resources in block optimisation.)

          • In practice, simplified heuristics are used to update new block-templates cost-effectively as mining is being performed.





          share|improve this answer






















            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "308"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            noCode: true, onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fbitcoin.stackexchange.com%2fquestions%2f84027%2fgetting-transactions-from-mempool-to-block%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            You can start to work in a block at any moment, you can even mine an empty block. If any new transaction arrives you rebuild the merkle tree and continue.






            share|improve this answer























            • So there is a possibilty to choose how many transactions is ok to start minning? Will the adding new transaction to potential block reset the minning (reset the nonce to zero)?

              – Konrad
              Jan 27 at 11:58















            1














            You can start to work in a block at any moment, you can even mine an empty block. If any new transaction arrives you rebuild the merkle tree and continue.






            share|improve this answer























            • So there is a possibilty to choose how many transactions is ok to start minning? Will the adding new transaction to potential block reset the minning (reset the nonce to zero)?

              – Konrad
              Jan 27 at 11:58













            1












            1








            1







            You can start to work in a block at any moment, you can even mine an empty block. If any new transaction arrives you rebuild the merkle tree and continue.






            share|improve this answer













            You can start to work in a block at any moment, you can even mine an empty block. If any new transaction arrives you rebuild the merkle tree and continue.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 27 at 11:41









            Osias JotaOsias Jota

            713215




            713215












            • So there is a possibilty to choose how many transactions is ok to start minning? Will the adding new transaction to potential block reset the minning (reset the nonce to zero)?

              – Konrad
              Jan 27 at 11:58

















            • So there is a possibilty to choose how many transactions is ok to start minning? Will the adding new transaction to potential block reset the minning (reset the nonce to zero)?

              – Konrad
              Jan 27 at 11:58
















            So there is a possibilty to choose how many transactions is ok to start minning? Will the adding new transaction to potential block reset the minning (reset the nonce to zero)?

            – Konrad
            Jan 27 at 11:58





            So there is a possibilty to choose how many transactions is ok to start minning? Will the adding new transaction to potential block reset the minning (reset the nonce to zero)?

            – Konrad
            Jan 27 at 11:58











            1














            While mining is done by specialized hardware, transaction choosing and merkle root calculating is done by the node software. While the specialized hardware is mining, a node may (and will) update its mempool continuously, and will calculate a new merkle root every few seconds. The mining hardware will check for header-template updates often, (and this instantaneous process is done without needing a restart), and will continue mining. The interval of header updates is chosen by the pool, and one of the aims is not to do it too often, or it'll waste the bandwidth






            share|improve this answer























            • I'm not sure that I understand, I thougt that merkle tree is taken to the block, so updating list of transactions will somehow start minning again? (Reset the nonce to zero)

              – Konrad
              Jan 27 at 11:56











            • Yes, they can reset the nonce.

              – MCCCS
              Jan 27 at 12:32











            • So this will not complicate mining? I mean after reseting the nonce we are starting again so we are not as close to winning as we were before reseting the nonce (I guess)

              – Konrad
              Jan 27 at 13:20







            • 1





              No, reseting the nonce with a different block template is not repeating the same POW, as the header hash will be different with the same nonce. (Same nonce, but different merkle-root)

              – James C.
              Jan 27 at 15:15











            • Increase or decreasing a nounce don't make you any closer or far from finding a block. Otherwise you would just go straight to the highest nounce. Any order you try nounces is good.

              – Osias Jota
              Jan 28 at 0:45
















            1














            While mining is done by specialized hardware, transaction choosing and merkle root calculating is done by the node software. While the specialized hardware is mining, a node may (and will) update its mempool continuously, and will calculate a new merkle root every few seconds. The mining hardware will check for header-template updates often, (and this instantaneous process is done without needing a restart), and will continue mining. The interval of header updates is chosen by the pool, and one of the aims is not to do it too often, or it'll waste the bandwidth






            share|improve this answer























            • I'm not sure that I understand, I thougt that merkle tree is taken to the block, so updating list of transactions will somehow start minning again? (Reset the nonce to zero)

              – Konrad
              Jan 27 at 11:56











            • Yes, they can reset the nonce.

              – MCCCS
              Jan 27 at 12:32











            • So this will not complicate mining? I mean after reseting the nonce we are starting again so we are not as close to winning as we were before reseting the nonce (I guess)

              – Konrad
              Jan 27 at 13:20







            • 1





              No, reseting the nonce with a different block template is not repeating the same POW, as the header hash will be different with the same nonce. (Same nonce, but different merkle-root)

              – James C.
              Jan 27 at 15:15











            • Increase or decreasing a nounce don't make you any closer or far from finding a block. Otherwise you would just go straight to the highest nounce. Any order you try nounces is good.

              – Osias Jota
              Jan 28 at 0:45














            1












            1








            1







            While mining is done by specialized hardware, transaction choosing and merkle root calculating is done by the node software. While the specialized hardware is mining, a node may (and will) update its mempool continuously, and will calculate a new merkle root every few seconds. The mining hardware will check for header-template updates often, (and this instantaneous process is done without needing a restart), and will continue mining. The interval of header updates is chosen by the pool, and one of the aims is not to do it too often, or it'll waste the bandwidth






            share|improve this answer













            While mining is done by specialized hardware, transaction choosing and merkle root calculating is done by the node software. While the specialized hardware is mining, a node may (and will) update its mempool continuously, and will calculate a new merkle root every few seconds. The mining hardware will check for header-template updates often, (and this instantaneous process is done without needing a restart), and will continue mining. The interval of header updates is chosen by the pool, and one of the aims is not to do it too often, or it'll waste the bandwidth







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 27 at 11:41









            MCCCSMCCCS

            4,44931444




            4,44931444












            • I'm not sure that I understand, I thougt that merkle tree is taken to the block, so updating list of transactions will somehow start minning again? (Reset the nonce to zero)

              – Konrad
              Jan 27 at 11:56











            • Yes, they can reset the nonce.

              – MCCCS
              Jan 27 at 12:32











            • So this will not complicate mining? I mean after reseting the nonce we are starting again so we are not as close to winning as we were before reseting the nonce (I guess)

              – Konrad
              Jan 27 at 13:20







            • 1





              No, reseting the nonce with a different block template is not repeating the same POW, as the header hash will be different with the same nonce. (Same nonce, but different merkle-root)

              – James C.
              Jan 27 at 15:15











            • Increase or decreasing a nounce don't make you any closer or far from finding a block. Otherwise you would just go straight to the highest nounce. Any order you try nounces is good.

              – Osias Jota
              Jan 28 at 0:45


















            • I'm not sure that I understand, I thougt that merkle tree is taken to the block, so updating list of transactions will somehow start minning again? (Reset the nonce to zero)

              – Konrad
              Jan 27 at 11:56











            • Yes, they can reset the nonce.

              – MCCCS
              Jan 27 at 12:32











            • So this will not complicate mining? I mean after reseting the nonce we are starting again so we are not as close to winning as we were before reseting the nonce (I guess)

              – Konrad
              Jan 27 at 13:20







            • 1





              No, reseting the nonce with a different block template is not repeating the same POW, as the header hash will be different with the same nonce. (Same nonce, but different merkle-root)

              – James C.
              Jan 27 at 15:15











            • Increase or decreasing a nounce don't make you any closer or far from finding a block. Otherwise you would just go straight to the highest nounce. Any order you try nounces is good.

              – Osias Jota
              Jan 28 at 0:45

















            I'm not sure that I understand, I thougt that merkle tree is taken to the block, so updating list of transactions will somehow start minning again? (Reset the nonce to zero)

            – Konrad
            Jan 27 at 11:56





            I'm not sure that I understand, I thougt that merkle tree is taken to the block, so updating list of transactions will somehow start minning again? (Reset the nonce to zero)

            – Konrad
            Jan 27 at 11:56













            Yes, they can reset the nonce.

            – MCCCS
            Jan 27 at 12:32





            Yes, they can reset the nonce.

            – MCCCS
            Jan 27 at 12:32













            So this will not complicate mining? I mean after reseting the nonce we are starting again so we are not as close to winning as we were before reseting the nonce (I guess)

            – Konrad
            Jan 27 at 13:20






            So this will not complicate mining? I mean after reseting the nonce we are starting again so we are not as close to winning as we were before reseting the nonce (I guess)

            – Konrad
            Jan 27 at 13:20





            1




            1





            No, reseting the nonce with a different block template is not repeating the same POW, as the header hash will be different with the same nonce. (Same nonce, but different merkle-root)

            – James C.
            Jan 27 at 15:15





            No, reseting the nonce with a different block template is not repeating the same POW, as the header hash will be different with the same nonce. (Same nonce, but different merkle-root)

            – James C.
            Jan 27 at 15:15













            Increase or decreasing a nounce don't make you any closer or far from finding a block. Otherwise you would just go straight to the highest nounce. Any order you try nounces is good.

            – Osias Jota
            Jan 28 at 0:45






            Increase or decreasing a nounce don't make you any closer or far from finding a block. Otherwise you would just go straight to the highest nounce. Any order you try nounces is good.

            – Osias Jota
            Jan 28 at 0:45












            1














            Producing the optimal block-template to mine is a NP-hard problem.



            The optimal block-template includes the highest sat/byte(or weight) transactions to maximise the miner reward. Assuming this computation and propagation of the perfect block-template took no time, it would make sense to update the block-template for each new transaction accepted to the memo-pool, as this new transaction could potentially increase the block reward. In this hypothetical scenario, the mining hardware is continuously working (hashing) and continuously updating the block header for a better block reward.



            However, since producing the optimal block-template is NP-hard, it takes significant time/cost to compute the optimal block-template from the mempool at any point in time:



            • Knapsack problem - maximise total fee value in block

            • Maximum independent vertex set - ensure no two tx spend the same output.

            Both problems scale exponentially and are expensive. This cost could have been invested in more hash-rate.



            Therefore, there is a trade-off between block optimisation and mining utilization.



            • Continuously optimising for a better block-template represents a cost in itself, which could be invested in more mining hash rate.

            • There exists a financial optimum, where suboptimal blocks-templates are mined, whilst mining equipment is fully utilised.

            • (One extreme could be mining empty blocks, maximising the number of hashes performed, whilst spending zero resources in block optimisation.)

            • In practice, simplified heuristics are used to update new block-templates cost-effectively as mining is being performed.





            share|improve this answer



























              1














              Producing the optimal block-template to mine is a NP-hard problem.



              The optimal block-template includes the highest sat/byte(or weight) transactions to maximise the miner reward. Assuming this computation and propagation of the perfect block-template took no time, it would make sense to update the block-template for each new transaction accepted to the memo-pool, as this new transaction could potentially increase the block reward. In this hypothetical scenario, the mining hardware is continuously working (hashing) and continuously updating the block header for a better block reward.



              However, since producing the optimal block-template is NP-hard, it takes significant time/cost to compute the optimal block-template from the mempool at any point in time:



              • Knapsack problem - maximise total fee value in block

              • Maximum independent vertex set - ensure no two tx spend the same output.

              Both problems scale exponentially and are expensive. This cost could have been invested in more hash-rate.



              Therefore, there is a trade-off between block optimisation and mining utilization.



              • Continuously optimising for a better block-template represents a cost in itself, which could be invested in more mining hash rate.

              • There exists a financial optimum, where suboptimal blocks-templates are mined, whilst mining equipment is fully utilised.

              • (One extreme could be mining empty blocks, maximising the number of hashes performed, whilst spending zero resources in block optimisation.)

              • In practice, simplified heuristics are used to update new block-templates cost-effectively as mining is being performed.





              share|improve this answer

























                1












                1








                1







                Producing the optimal block-template to mine is a NP-hard problem.



                The optimal block-template includes the highest sat/byte(or weight) transactions to maximise the miner reward. Assuming this computation and propagation of the perfect block-template took no time, it would make sense to update the block-template for each new transaction accepted to the memo-pool, as this new transaction could potentially increase the block reward. In this hypothetical scenario, the mining hardware is continuously working (hashing) and continuously updating the block header for a better block reward.



                However, since producing the optimal block-template is NP-hard, it takes significant time/cost to compute the optimal block-template from the mempool at any point in time:



                • Knapsack problem - maximise total fee value in block

                • Maximum independent vertex set - ensure no two tx spend the same output.

                Both problems scale exponentially and are expensive. This cost could have been invested in more hash-rate.



                Therefore, there is a trade-off between block optimisation and mining utilization.



                • Continuously optimising for a better block-template represents a cost in itself, which could be invested in more mining hash rate.

                • There exists a financial optimum, where suboptimal blocks-templates are mined, whilst mining equipment is fully utilised.

                • (One extreme could be mining empty blocks, maximising the number of hashes performed, whilst spending zero resources in block optimisation.)

                • In practice, simplified heuristics are used to update new block-templates cost-effectively as mining is being performed.





                share|improve this answer













                Producing the optimal block-template to mine is a NP-hard problem.



                The optimal block-template includes the highest sat/byte(or weight) transactions to maximise the miner reward. Assuming this computation and propagation of the perfect block-template took no time, it would make sense to update the block-template for each new transaction accepted to the memo-pool, as this new transaction could potentially increase the block reward. In this hypothetical scenario, the mining hardware is continuously working (hashing) and continuously updating the block header for a better block reward.



                However, since producing the optimal block-template is NP-hard, it takes significant time/cost to compute the optimal block-template from the mempool at any point in time:



                • Knapsack problem - maximise total fee value in block

                • Maximum independent vertex set - ensure no two tx spend the same output.

                Both problems scale exponentially and are expensive. This cost could have been invested in more hash-rate.



                Therefore, there is a trade-off between block optimisation and mining utilization.



                • Continuously optimising for a better block-template represents a cost in itself, which could be invested in more mining hash rate.

                • There exists a financial optimum, where suboptimal blocks-templates are mined, whilst mining equipment is fully utilised.

                • (One extreme could be mining empty blocks, maximising the number of hashes performed, whilst spending zero resources in block optimisation.)

                • In practice, simplified heuristics are used to update new block-templates cost-effectively as mining is being performed.






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 27 at 15:14









                James C.James C.

                1,8301214




                1,8301214



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Bitcoin Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fbitcoin.stackexchange.com%2fquestions%2f84027%2fgetting-transactions-from-mempool-to-block%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown






                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?