bitzenyPlus / BitZenyPlus

[in progress] BitZeny Plus integration/staging tree created by the New Dev team
https://bitzeny.tech/
MIT License
11 stars 3 forks source link

[v3.0-dev] serialize input to yespower_tls() #43

Closed cryptozeny closed 5 years ago

cryptozeny commented 5 years ago

Original post: https://github.com/KotoDevelopers/koto/issues/18

I searched v3.0-dev branch and found...


https://github.com/bitzenyPlus/BitZenyPlus/blob/31e94151a95592fd867b394813673a3353e0a342/src/hash.h#L237

template<typename T>
uint256 SerializeHashYespower(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
{
    CHashWriterYespower ss(nType, nVersion);
    ss << obj;
    return ss.GetHash();
}

https://github.com/bitzenyPlus/BitZenyPlus/blob/31e94151a95592fd867b394813673a3353e0a342/src/primitives/block.cpp#L15

uint256 CBlockHeader::GetHash() const
{
    return SerializeHashYespower(*this);
}

I wonder if we have already serialized or need more work. :thinking:

Lesmiscore commented 5 years ago

https://github.com/bitzenyPlus/BitZenyPlus/blob/31e94151a95592fd867b394813673a3353e0a342/src/hash.h#L240 Looks like we serialize the block header here.

cryptozeny commented 5 years ago

I think so. Do I not have to worry anymore?

solardiz commented 5 years ago

I am replying out-of-context, but from what I see here it looks like you do serialize, but you need to worry about GetHash being very slow. Like I wrote in yespower documentation, there are two primary ways to introduce a slow verification PoW into a Bitcoin core based tree: either you introduce a separate GetPoWHash and use it where appropriate (Litecoin, Koto) or you introduce caching of PoW results (YACoin, Cryply). What I see on this issue (sorry, didn't review the code in context) looks like neither, and I expect unacceptably poor performance as the blockchain grows.

cryptozeny commented 5 years ago

@solardiz You are right. Block verification is crazy slow...😭 The blockchain size is 4GB and sync takes over 5 days! 😨 We want to speed up... 😵

cryptozeny commented 5 years ago

https://github.com/bitzenyPlus/BitZenyPlus/blob/31e94151a95592fd867b394813673a3353e0a342/src/crypto/yespower/README#L147

To integrate yespower in an altcoin based on Bitcoin Core, you might
invoke yespower_tls() from either a maybe-new (depending on where you
fork from) CBlockHeader::GetPoWHash() (and invoke that where PoW is
needed like e.g. Litecoin does for scrypt) or CBlockHeader::GetHash()
(and implement caching for its return value like e.g. YACoin does for
scrypt).  Further detail on this (generating new genesis blocks, etc.)
is not yespower-specific and thus is not provided here.  Just like (and
even more so than) yespower itself, this guidance is provided as-is and
without guarantee of being correct and safe to follow.  You're supposed
to know what you're doing.
cryptozeny commented 5 years ago

Now I am trying to fix it. I think it takes a long time... :snail: :turtle: I will reopen the issue. The first is introduce GetPoWHash and the second is serialize input. The two are different issues.