Post
Topic
Board Development & Technical Discussion
Re: A useful PoW without replacing Nakamoto Consensus
by
kernel1983
on 01/11/2022, 11:46:37 UTC
Code:
import hashlib

BYTES_TO_ENCODE = b'\x01\x05\xff\xcc'
PREVIOUS_BLOCK_HASH = b'\x00' * 64
TXS = b'RANDOM TRANSACTIONS TO BE INCLUDED IN THE NEXT BLOCK'

difficulty = 10
nonce = 0
encode_offset = 0

while True:
    nonce += 1
    if nonce % 1000000 == 0:
        print(nonce, encode_offset)
    hash = hashlib.sha256(PREVIOUS_BLOCK_HASH+TXS+str(nonce).encode()).hexdigest()
    if hash.startswith('0' * difficulty):
        break

    if hash.endswith('%02x' % BYTES_TO_ENCODE[encode_offset]):
        print('hex %02x nonce' % BYTES_TO_ENCODE[encode_offset], nonce)
        encode_offset += 1
        if encode_offset >= len(BYTES_TO_ENCODE):
            break


The nonce are the enocded value.

We did not change the rule of consensus, the block difficulty is the start of the hash. (left bytes)
But just adding a check for the end of the hash to see if it is equal to the byte we want to encode. (right bytes)

In general, I don't think a blockchain is the right data structure for decentralized file hosting.
Me neither, that's why I think this proposal, filecoin included, is fundamentally flawed. If I want to share a file, I'm the one who first of all have to take personal responsibility of the file, and second, pay the required cost. There's no reason a hundred miners keep my file when I only need one to store it. That's the definition of inefficiency. If I want true decentralization of my file storage, then I should run a BitTorrent client, and seed my stuff there. If I don't care about that (which I honestly don't), I can stick with a centralized solution, such as Mega Upload. Privacy can be assured with encryption.

And that's before I even comprehend (2 pages now) how Proof-of-Work can help the situation in decentralized file sharing / storage. It's just flawed, no need to. Blockchains solve the double-spending problem, and that's all they do.

Maybe it is true.
However, if I did not step into the detail of Filecoin, I will never realize that PoW can be upgraded. (Now lots of people turns to PoS, what a pity!)

Compare to other blockchain storage project, I will say EcoPoW based blockchain is totally different.
It is not just a blockchain storage, this is the key to build a more decenterization blockchain!

I can foresee the storage feature become the source of PoW computation, since we all know that coin price will not go up forever.