Jorge TimĂłn [ARCHIVE] on Nostr: đź“… Original date posted:2015-08-20 đź“ť Original message:On Thu, Aug 20, 2015 at ...
đź“… Original date posted:2015-08-20
đź“ť Original message:On Thu, Aug 20, 2015 at 9:14 AM, Tamas Blummer <tamas at bitsofproof.com> wrote:
> Jorge,
>
> separating script engine into libconsensus was very helpful, since wrapped
> the piece of consensus
> that would least likely to be captured exactly with an implementation from
> scratch. Thank you for your
> effort there. Bits of Proof now uses its own or alternatively libconsensus
> for full validation.
It wasn't just me: I didn't had the idea of creating a libconsensus
with a C API (thank Matt Corallo for that), I didn't removed all the
undesired dependencies or prepared the building part (thank Cory
Fields) and also thank at least Wladimir and Pieter who also
contributed in some ways I don't remember.
And of course also thank all the reviewers that made the PR merges possible.
I'm really happy to hear that libconsensus is being used, thank you
for your effort there too.
> I am sceptical however that a “full” consensus lib extracted from satoshi’s
> code is worth trying.
> Not because it was impossible, but because the result would not be higher
> quality, if measured on agreement
> with satoshi, than other re-implementations. It would actually be lower
> quality because of the antique tool set.
I don't understand what you mean by "quality" in this context. One of
the goals is to have as little dependencies as possible (so "more
modern tool sets" may not be suitable for libconsensus). libsecp256k1
will keep on being a dependency (highly optimized C code) and that's
about it.
Ideally I would like to slowly move libconsensus from C++ to C too,
but it seems other people would prefer to move to C++11 instead.
> The rules outside script engine are simpler, therefore much easier to
> capture exactly. They are however
> scattered around in the spaghetti and are often just a single if statement,
> also repeated elsewhere.
Yes, they are simpler and thus there's less risks of consensus fork
bugs, but it still exists.
It is true that the consensus code is currently spread all around
(specially in main.cpp), but completing libconsensus would solve that.
Lastly, since for consensus rules "the code is the specification", it
is unfortunate that the specification is coupled with a concrete
implementation (Bitcoin Core) and we should fix that.
> You would either have to very extensively refactor the code, that unlikely
> goes through as a PR, or
> do what me and others did. Read satoshi code and rewrite the same. You have
> a slight advantage of copy-paste small fragments, but I doubt the consensus
> relevant advantage of that.
But the goal is not reimplementing the consensus rules but rather
extract them from Bitcoin Core so that nobody needs to re-implement
them again.
It is not only exposing it but also separating it from Bitcoin Core so
that they can be changed without having to also change/take into
account non-consensus Bitcoin Core specific things.
A single PR would certainly be unacceptable, I was making many little
more acceptable ones (some of them already merged):
* [1/9] Consensus
** MERGED or DELETED
*** MERGED Consensus: Decouple pow from chainparams #5812 [consensuspow]
*** MERGED MOVEONLY: Move constants and globals to consensus.h #5696
[consensus_policy0]
*** DELETED Refactor: Create CCoinsViewEfficient interface for
CCoinsViewCache #5747 [coins]
*** MERGED Chainparams: Refactor: Decouple IsSuperMajority from
Params() #5968 [params_consensus]
*** MERGED Remove redundant getter
CChainParams::SubsidyHalvingInterval() #5996 [params_subsidy]
*** MERGED Separate CValidationState from main #5669 [consensus]
*** DELETED Consensus: Refactor: Separate CheckFinalTx from
main::IsFinalTx #6063 [consensus_finaltx]
*** MERGED Consensus: Decouple ContextualCheckBlockHeader from
checkpoints #5975 [consensus_checkpoints]
*** MERGED Separate Consensus::CheckTxInputs and GetSpendHeight in
CheckInputs #6061 [consensus_inputs]
*** MERGED Bugfix: Don't check the genesis block header before
accepting it #6299 [5975-quick-fix]
** REBASE Chainparams: Explicit Consensus::Params arg in consensus
functions #6024 [params_consensus2]
** REBASE Optimizations: Consensus: In AcceptToMemoryPool,
ConnectBlock, and CreateNewBlock #6445 [consensus-txinputs-0.12.99]
** REBASE MOVEONLY: Move most of consensus functions (pre-block) #6051
[consensus_moveonly]
** REBASE Consensus: Refactor: Turn CBlockIndex::GetMedianTimePast
into independent function #6009 [consensus_mediantime]
** DEPENDENT Consensus: Refactor: Consensus version of
CheckBlockHeader() #6035 [consensus_checkblockheader]
** DEPENDENT Consensus: Consensus version of pow functions [consensus_pow2]
** DEPENDENT API: Expose bitcoinconsensus_verify_header() in
libconsensus #5995 [consensus_header]
** DEPENDENT API: Expose bitcoinconsensus_verify_block() in
libconsensus #5946 [consensus_tip]
Published at
2023-06-07 15:48:44Event JSON
{
"id": "ce2b48ee162cb17e67b7b9bd3df5aeda7930013596615d0426a2027b7957c2ed",
"pubkey": "498a711971f8a0194289aee037a4c481a99e731b5151724064973cc0e0b27c84",
"created_at": 1686152924,
"kind": 1,
"tags": [
[
"e",
"2cb77a81d8c40c165dca19129371f9698d50bec611bf964a3c59cbb47a7d1941",
"",
"root"
],
[
"e",
"df169c874fe5fa4682aa458d868ca68172e319ceb446b56464d8638dcb72d9c7",
"",
"reply"
],
[
"p",
"c632841665fccdabf021322b1d969539c9c1f829ceed38844fea24e8512962d7"
]
],
"content": "📅 Original date posted:2015-08-20\n📝 Original message:On Thu, Aug 20, 2015 at 9:14 AM, Tamas Blummer \u003ctamas at bitsofproof.com\u003e wrote:\n\u003e Jorge,\n\u003e\n\u003e separating script engine into libconsensus was very helpful, since wrapped\n\u003e the piece of consensus\n\u003e that would least likely to be captured exactly with an implementation from\n\u003e scratch. Thank you for your\n\u003e effort there. Bits of Proof now uses its own or alternatively libconsensus\n\u003e for full validation.\n\nIt wasn't just me: I didn't had the idea of creating a libconsensus\nwith a C API (thank Matt Corallo for that), I didn't removed all the\nundesired dependencies or prepared the building part (thank Cory\nFields) and also thank at least Wladimir and Pieter who also\ncontributed in some ways I don't remember.\nAnd of course also thank all the reviewers that made the PR merges possible.\n\nI'm really happy to hear that libconsensus is being used, thank you\nfor your effort there too.\n\n\u003e I am sceptical however that a “full” consensus lib extracted from satoshi’s\n\u003e code is worth trying.\n\u003e Not because it was impossible, but because the result would not be higher\n\u003e quality, if measured on agreement\n\u003e with satoshi, than other re-implementations. It would actually be lower\n\u003e quality because of the antique tool set.\n\nI don't understand what you mean by \"quality\" in this context. One of\nthe goals is to have as little dependencies as possible (so \"more\nmodern tool sets\" may not be suitable for libconsensus). libsecp256k1\nwill keep on being a dependency (highly optimized C code) and that's\nabout it.\nIdeally I would like to slowly move libconsensus from C++ to C too,\nbut it seems other people would prefer to move to C++11 instead.\n\n\u003e The rules outside script engine are simpler, therefore much easier to\n\u003e capture exactly. They are however\n\u003e scattered around in the spaghetti and are often just a single if statement,\n\u003e also repeated elsewhere.\n\nYes, they are simpler and thus there's less risks of consensus fork\nbugs, but it still exists.\nIt is true that the consensus code is currently spread all around\n(specially in main.cpp), but completing libconsensus would solve that.\nLastly, since for consensus rules \"the code is the specification\", it\nis unfortunate that the specification is coupled with a concrete\nimplementation (Bitcoin Core) and we should fix that.\n\n\u003e You would either have to very extensively refactor the code, that unlikely\n\u003e goes through as a PR, or\n\u003e do what me and others did. Read satoshi code and rewrite the same. You have\n\u003e a slight advantage of copy-paste small fragments, but I doubt the consensus\n\u003e relevant advantage of that.\n\nBut the goal is not reimplementing the consensus rules but rather\nextract them from Bitcoin Core so that nobody needs to re-implement\nthem again.\nIt is not only exposing it but also separating it from Bitcoin Core so\nthat they can be changed without having to also change/take into\naccount non-consensus Bitcoin Core specific things.\nA single PR would certainly be unacceptable, I was making many little\nmore acceptable ones (some of them already merged):\n\n* [1/9] Consensus\n** MERGED or DELETED\n*** MERGED Consensus: Decouple pow from chainparams #5812 [consensuspow]\n*** MERGED MOVEONLY: Move constants and globals to consensus.h #5696\n[consensus_policy0]\n*** DELETED Refactor: Create CCoinsViewEfficient interface for\nCCoinsViewCache #5747 [coins]\n*** MERGED Chainparams: Refactor: Decouple IsSuperMajority from\nParams() #5968 [params_consensus]\n*** MERGED Remove redundant getter\nCChainParams::SubsidyHalvingInterval() #5996 [params_subsidy]\n*** MERGED Separate CValidationState from main #5669 [consensus]\n*** DELETED Consensus: Refactor: Separate CheckFinalTx from\nmain::IsFinalTx #6063 [consensus_finaltx]\n*** MERGED Consensus: Decouple ContextualCheckBlockHeader from\ncheckpoints #5975 [consensus_checkpoints]\n*** MERGED Separate Consensus::CheckTxInputs and GetSpendHeight in\nCheckInputs #6061 [consensus_inputs]\n*** MERGED Bugfix: Don't check the genesis block header before\naccepting it #6299 [5975-quick-fix]\n** REBASE Chainparams: Explicit Consensus::Params arg in consensus\nfunctions #6024 [params_consensus2]\n** REBASE Optimizations: Consensus: In AcceptToMemoryPool,\nConnectBlock, and CreateNewBlock #6445 [consensus-txinputs-0.12.99]\n** REBASE MOVEONLY: Move most of consensus functions (pre-block) #6051\n[consensus_moveonly]\n** REBASE Consensus: Refactor: Turn CBlockIndex::GetMedianTimePast\ninto independent function #6009 [consensus_mediantime]\n** DEPENDENT Consensus: Refactor: Consensus version of\nCheckBlockHeader() #6035 [consensus_checkblockheader]\n** DEPENDENT Consensus: Consensus version of pow functions [consensus_pow2]\n** DEPENDENT API: Expose bitcoinconsensus_verify_header() in\nlibconsensus #5995 [consensus_header]\n** DEPENDENT API: Expose bitcoinconsensus_verify_block() in\nlibconsensus #5946 [consensus_tip]",
"sig": "d6f33e7406843194271577e9622500f9a0435ee7ba01acd489631d6c8b6bb58abc9e7db34da7cb51b8cd53347993a7975dd39643cf009cc0d98061a31d5abe20"
}