Skip to content

Conversation

jtimon
Copy link
Contributor

@jtimon jtimon commented Oct 18, 2014

The main goal is to separate minimal core dependencies for script/interpreter. CFeeRate shouldn't be there, but that won't be move only.
This should help with #4692 and it's related to #4981 among other PRs

@theuni
Copy link
Member

theuni commented Oct 18, 2014

Missing some files.

Any reason not to go ahead and move CTxOutCompressor/CTxInUndo/CTxUndo while you're at it, as discussed on IRC?

@jtimon
Copy link
Contributor Author

jtimon commented Oct 18, 2014

Ok, I'll do a more complete PR, closing for now.

@jtimon jtimon closed this Oct 18, 2014
@sipa
Copy link
Member

sipa commented Oct 18, 2014

  • Can you move CTxOutCompressor either along with CTransaction (it doesn't depend on anything block, right?), or directly to coins.h.
  • Can you move the remaining part to a coins/block.h? coins.h and coins/transaction.h is a bit strange.

@jtimon
Copy link
Contributor Author

jtimon commented Oct 18, 2014

  1. I don't want to put compressor in core/transaction since script/interpreter doesn't need it.
  2. undotx depends on txcompressor but not on the rest of coins.o

That means txcompressor goes on its own (maybe take script/compressor with it?)

  1. I don't like to have compressor in chain
  2. I don't want to be responsible for putting more stuff in main

Does that mean txundo goes on its own as well?
I think so, but please debate 3 and 4.

@gmaxwell
Copy link
Contributor

logically the compressor stuff is part of coins-- its the fancy, locally specific highly compressed seralization used only in the utxo set representation. Is there any reason it can't just go into coins.cpp/coins.h?

Undo seem logically best placed with chain.* though it's a bit different since undo data (like the compressor) is only locally significant, most of chain.* is actually locally specific storage stuff for the chain in any case.

@jtimon
Copy link
Contributor Author

jtimon commented Oct 18, 2014

Never mind, coins.o also depends on CTxInUndo so they both belong in their own files.

@jtimon
Copy link
Contributor Author

jtimon commented Oct 18, 2014

logically the compressor stuff is part of coins-- its the fancy, locally
specific highly compressed seralization used only in the utxo set
representation. Is there any reason it can't just go into coins.cpp/coins.h?

Txundo depends on it but not in the rest of coins.
@theuni also mentioned that moving it to coins caused a circular dependency
with main.
Additionally, script/compressor could be moved there too, since it's the
only placed where it's used.

Undo seem logically best placed with chain.* though it's a bit different
since undo data (like the compressor) is only locally significant, most of
chain.* is actually locally specific storage stuff for the chain in any
case.

CChain and CTxUndo don't depend on each other, why should they go together?
About moving it to main...I am of the opinion that main should be
dismembered in many small pieces and this wouldn't help to move in that
direction.
I'm generally in favor of many small files over a few big ones. It is more
readable to me and it's also more flexible for later refactors.

@jtimon
Copy link
Contributor Author

jtimon commented Oct 18, 2014

Oh, and coins depends on CTxInUndo but not in chain or main.

@jtimon jtimon reopened this Oct 18, 2014
@jtimon jtimon force-pushed the core branch 2 times, most recently from d0fe1cb to 5a3ff87 Compare October 18, 2014 17:39
@jtimon
Copy link
Contributor Author

jtimon commented Oct 18, 2014

Mhmm, blockundo can get out of main too.
Should txundo and blockundo go together in undo.h or each separated (ie undotx and undoblock) so that coins doesn't have to include undoblock ?

@sipa
Copy link
Member

sipa commented Oct 18, 2014

So undo data (CTxInUndo, CTxUndo, CBlockUndo) is is not directly depended on by chain, but CBlockIndex (in chain) contains references to where undo data is on disk, which makes it sort-of related. I'm fine with a separate file too.

To avoid coins from depending on undo (or chain), CCoins::Spend could become a method (or function) on CTxInUndo. I think that method doesn't logically belong in coins anyway.

@jtimon
Copy link
Contributor Author

jtimon commented Oct 18, 2014

Ok, so here's the plan:

  1. Decouple coins from undo as suggested by @sipa
  2. Move txundo to undo
  3. Move TxCompressor and script/compressor to coins
  4. Move blockundo to undo

I also want to decouple txout from feerate and move it out of core/transaction (to policy/fee ?) but I'll leave that for a later PR.

@@ -0,0 +1,59 @@
// Copyright (c) 2012-2013 The Bitcoin developers
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Why only 2013?

@jtimon jtimon force-pushed the core branch 2 times, most recently from 13d22e9 to 4f8d319 Compare October 19, 2014 07:41
@sipa
Copy link
Member

sipa commented Oct 19, 2014

Can you move CBlockUndo to undo as well?

// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_CORE_H
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Rename and edit end comment?

@Diapolo
Copy link

Diapolo commented Oct 19, 2014

Suggestion: After this is confirmed to be move-only etc. create a last pull, which does the clang-formatting!?

@jtimon jtimon force-pushed the core branch 2 times, most recently from 9c5f844 to 3004ad3 Compare October 20, 2014 02:02
@jtimon
Copy link
Contributor Author

jtimon commented Oct 20, 2014

I ended up starting with moving CFeeRate and the Amount constants to amount.o so I had to rebase and I included the nits. I added a last clang commit as suggested.
CBlockUndo depends on CDiskBlockPos, so I'll leave that for another PR.
There's something that is not purely move-only, so someone reviewing the move-only should notice.

@sipa
Copy link
Member

sipa commented Oct 20, 2014

An alternative would be moving the undo stuff to chain.h (it's about auxiliary data about chain validation). I prefer to have all undo stuff together :)

@jtimon
Copy link
Contributor Author

jtimon commented Oct 23, 2014

I needed to rebase on top of master due to some minor include conflicts.
Then I needed to fix some missing includes: git is smart but not enough to figure includes by itself.
The latest couple of commits should solve it.

@theuni
Copy link
Member

theuni commented Oct 23, 2014

ACK

@sipa
Copy link
Member

sipa commented Oct 27, 2014

The clang fix included here makes the result much harder to review. Can you remove that? We'll do the clang fixes all at once before release, without mixing it with other changes. Sorry, @Diapolo - we'll get to it!

@sipa
Copy link
Member

sipa commented Oct 27, 2014

Also, feel free to rebase & squash. As long as all commits are move-only, it's easy to check with git diff merge~:src..merge:dest.

@jtimon
Copy link
Contributor Author

jtimon commented Oct 27, 2014

Left the clang change out. Not sure if it's worth it to make a separate PR though. Aren't we applying clang to everything just before 0.10 ?

@sipa
Copy link
Member

sipa commented Oct 27, 2014

@jtimon yes, that's what I meant - let's not bother with clang fixes now, as we'll do it all at once right before the 0.10 release.

@sipa
Copy link
Member

sipa commented Oct 27, 2014

ACK - verified move-only. Do you plan on moving CBlockUndo to undo.h as well (after turning its read/write methods into main.cpp functions) ?

@jtimon
Copy link
Contributor Author

jtimon commented Oct 27, 2014

sipa Since too many of my open PRs depend this I plan to do that in a later PR.

@sipa
Copy link
Member

sipa commented Oct 27, 2014

Sure, a later PR sounds good.

@jtimon
Copy link
Contributor Author

jtimon commented Oct 27, 2014

Done, CBlockUndo is moved to undo.h as part of #5111.

#ifndef H_BITCOIN_TXUNDO
#define H_BITCOIN_TXUNDO

#include "compressor.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a trailing space here.

@TheBlueMatt
Copy link
Contributor

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ACK commithash 99f41b9cf7b8e039cea75500a905498a1f6969f3 (-trailing space)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBAgAGBQJUTs7GAAoJEIm7uGY+LmXOSsYP/2iM4ZuhSAowA7brZAwrzJCE
YvuhbiY5pVS0OyRtiudWpsHhmQVhB/Be19+YltOZduNo8fAPVRJ68yL/Y8fIlXAQ
ljy/UTNRMlbqKZB9I2W87VHP0aTZy7XlPlVwMP60JjOtXkNVVNzDh19Kytf2ukKP
lEWo3UcxM2LTpI1YmXQxW9cRhkjgmY7DFQ6raC60b7BIZhgmRVJQRHC1c+iDJDF1
yuIF39fFNS/SyCsdKmzq76Hj0BH2wX8T5+LWbxP1AkFjKmeN0Sxq2W1Z3Bdyj/qd
dVFchpdWrVvmfXKh23L6dO6ZgCz523hDXBaRspLWZWPTK5VMiyQoDdulq+2luK2/
odgSJ/K8oHKpJJcVgsak0JSAW88Aa7sRJZm8QgWi5Ru/vvFob81CCfw3fbjIDpz/
6yTv+XVaxbyODZ51iDwcmFzday6cA8o9L43DMbTvNIoN6S2rY3PAZIMN1oYhINQt
ex+CFyV2esP9taZfI8y7JTgsIz5oj5xGGsefqv9zr7QuGZthKxx/cTdzdGdEWCgl
FuEqisIQosLgO4nnx3Q5iRMhHoXNY0SLwrVJT1C07bzi+g8U5alSj+VgGqLa3i1I
gQXpe4bMOfiCbfPDmcu5z+SBIQO2mGMAG7ctzJ9K8QUsXJBXQnPHVkU0QC9id4de
XTpcHMUtWk3Nv6fFTkVo
=NWC1
-----END PGP SIGNATURE-----

@sipa
Copy link
Member

sipa commented Oct 28, 2014

@laanwj comments?

@laanwj
Copy link
Member

laanwj commented Oct 28, 2014

utACK

@sipa sipa merged commit 99f41b9 into bitcoin:master Oct 28, 2014
sipa added a commit that referenced this pull request Oct 28, 2014
99f41b9 MOVEONLY: core.o -> core/block.o (jtimon)
561e9e9 MOVEONLY: Move script/compressor out of script and put CTxOutCompressor (from core) with it (jtimon)
999a2ab MOVEONLY: separate CTxUndo out of core (jtimon)
4a3587d MOVEONLY: Separate CTransaction and dependencies from core (jtimon)
eda3733 MOVEONLY: Move CFeeRate and Amount constants to amount.o (jtimon)
@luke-jr
Copy link
Member

luke-jr commented Oct 30, 2014

$ git pull
remote: Counting objects: 255, done.
remote: Compressing objects: 100% (163/163), done.
remote: Total 255 (delta 131), reused 149 (delta 92)
Receiving objects: 100% (255/255), 385.22 KiB | 62.00 KiB/s, done.
Resolving deltas: 100% (131/131), done.
From git://github.com/bitcoin/bitcoin
   2ffdf21..723c752  master     -> origin/master
Updating 2ffdf21..723c752
error: The following untracked working tree files would be overwritten by merge:
    src/core
    src/core
    src/core
    src/core

I think it's a bad practice to name files/directories simply "core" (this breaks automatic coredumps on many systems) - can we call it something else?

@gmaxwell
Copy link
Contributor

On Unix-like systems core is a semi-magical file name since coredumps get written to it.

@jtimon
Copy link
Contributor Author

jtimon commented Oct 30, 2014

I suspect this wouldn't be a problem if we didn't had executables at /src but...
What about "datatypes", "core_structs", "serializable" or something along these lines?
We should have bikeshed before but we need to do it now as well...

@luke-jr
Copy link
Member

luke-jr commented Oct 30, 2014

datatypes +1

furszy added a commit to PIVX-Project/PIVX that referenced this pull request Jul 16, 2020
9670a84 Move UndoWriteToDisk() and UndoReadFromDisk() to anon namespace (random-zebra)
4fe609f Decouple CBlockUndo from CDiskBlockPos (jtimon)
9703b0e Decouple miner.o and txmempool.o from CTxUndo (random-zebra)
cdc8cdc Decouple CCoins from CTxInUndo (jtimon)

Pull request description:

  Backport bitcoin#5111

  Original description:
  > Built on top of bitcoin#5100.
  > coins.o doesn't need to depend on undo.h (Decouple CCoins from CTxInUndo)
  > miner.o neither (Decouple miner.o from CTxUndo)
  > Finally, CBlockUndo can be moved from main.h to undo.h if it is first decoupled from CDiskBlockPos.

ACKs for top commit:
  furszy:
    utACK 9670a84
  Fuzzbawls:
    re-utACK 9670a84

Tree-SHA512: d77110525f50a3085013ca9cb87550ff786ee06c5b938a9002fe3a434c7a35a425238d1b623a01c26bebb5075c7e1bea9bc2ff4638c0c1190df15196b7097e55
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants