-
jtgrassie
Raydar: it still "works"
-
Raydar
I appreciate the response jtgrassie! I'm trying to test this with my rpc endpoint running on stagenet with "--fixed-difficulty 5000".
-
Raydar
The daemon responds that the block does not have enough proof of work. Do you have an idea what the issue is?
-
Raydar
I don't have much experience with blockchain dev in general, so I'm struggling a bit.
-
Raydar
console output:
-
Raydar
E Block with id: <53c017e22cee7d690735366d67d46fbfa182b97b2731fe60979ae18479aec246>
-
Raydar
E for alternative chain, does not have enough proof of work: <0008d422f1b7ba9b946d794185bad669c02b570d5925486462589096fe3f9e87>
-
Raydar
E expected difficulty: 5000
-
Raydar
E mined block failed verification
-
Raydar
I'm running the solo-block.py from your github and I've just modified the rpc url and wallet address so far.
-
Raydar
-
moneromooo
The 000 at the start look suspiciously like something confusing little endian and big endian.
-
Raydar
Thanks +moneromoo. Unfortunately I don't think I understand enough to figure out how to fix that myself yet though.
-
Raydar
Along the way I finally just realized that I can use the rpc calc_pow method from the daemon to help validate hashes.
-
Raydar
At this stage however I'm still struggling to understand how that works though.
-
Raydar
Something simple like the solo-block.py would be perfect. I've tried picking in to the xmrig code, but that appears to be far beyond my current level .
-
moneromooo
Somewhere you're presumably converting a hash to/from binary/text. Double check that code.
-
moneromooo
Or checking whether a hash is below a target.
-
Raydar
hash = pyrx.get_rx_hash(bin, seed_hash, height)
-
Raydar
hex_hash = binascii.hexlify(hash)
-
Raydar
...
-
Raydar
if base_diff / int(hex_hash, 16) >= diff:
-
Raydar
...
-
Raydar
btb = binascii.hexlify(pack_nonce(btb, nonce))
-
Raydar
payload = {
-
Raydar
'jsonrpc': '2.0',
-
Raydar
'id': '0',
-
Raydar
'method': 'submit_block',
-
Raydar
'params': [btb.decode()]
-
Raydar
}
-
Raydar
I think this is where any binary/text converting takes place. is there anything obvious wrong there?
-
moneromooo
hexlify sounds like "converting a hash to/from binary/text".
-
moneromooo
I'm guessing it considers bytes, not multi byte values with an endianness.
-
moneromooo
The most significant byte of a hash is ((const uint8_t*)&hash)[31].
-
moneromooo
If you dump as a bytestream, you'll have ((const uint8_t*)&hash)[0].
-
moneromooo
So it looks like a plausible cause for your problem.
-
moneromooo
If you did not write that function, check whether it has a parameter to consider the value's endianness.
-
moneromooo
If not, write your own, or find another.
-
moneromooo
Or reverse hte hash bytes first, but that's just getting dodgy.
-
moneromooo
(and would have to be done all over the place)
-
moneromooo
Also, I don't know that API, but it looks like you might be converting a hash to hex text, then back to a hash ? Maybe using the original one will fix your problem, if it's hte same type.
-
moneromooo
Scratch that, it's python, it's probably lots of types you can't just cast even though it's the same thing underneath.
-
Raydar
:D Thanks so much for trying to help. Although I barely can follow along.
-
Raydar
I'm going to try anyway.
-
jtgrassie
Raydar: "running on stagenet with "--fixed-difficulty" <- Thats why your block is rejected!
-
jtgrassie
you're submitting a block at a lower difficulty than stagenet is currently demanding
-
jtgrassie
"The daemon responds that the block does not have enough proof of work." <- It's even telling you so.
-
Raydar
Sorry. I thought the daemon accepts lower difficulty blocks in this case and puts them in an alternate chain.
-
Raydar
Testing on the same node I see the following successful block submission from xmrig.
-
Raydar
I +++++ BLOCK SUCCESSFULLY ADDED
-
Raydar
I id: <8907dad539fd31dc811399df9fb40bd1c7d73df77e24db5c3e69294c30359ed7>
-
Raydar
I PoW: <3455f9465d83761b49ef61fde8743dfc4d7ebfa8c016460a0ceaf751f61f0300>
-
Raydar
I HEIGHT 1328802, difficulty: 5000
-
Raydar
Does this explain what I am doing wrong?
-
moneromooo
Blocks on an alt chain have to match the difficulty on their chain.
-
moneromooo
If you're using fixed difficulty, you obviously have to use the same fixed difficulty for all the parts of your setup.
-
moneromooo
FWIW, that block PoW looks better above. 00 at the end.
-
someoneelse49549
-
someoneelse49549
-
someoneelse49549
-
UkoeHB
someoneelse49549: "The subclass should return the hash of the transaction which created the output with the global index given, as well as its index in that transaction."
-
someoneelse49549
what is the global index?
-
UkoeHB
the output's index in the global set of outputs
-
UkoeHB
the ledger ^.^
-
someoneelse49549
alright thank you
-
moneromooo
The global set of outputs of the same amount, coinbases in v2 txes being deemed to have 0 amount.
-
someoneelse49549
moneromooo: so in output_amounts table, all rct outputs are under the same 0 key. While pre-rct outputs can have a different amount key right?
-
moneromooo
Yes.
-
someoneelse49549
Also, I can't find the pull request on github that deprecated the txs table. Do you have an idea where I can find the discussion about it ?
-
moneromooo
The pruning patch IIRC.
-
Raydar
I'm sorry to carry on about this. The fixed difficulty if correctly recognized by the demo miner from jtgrassie. It shows Target difficulty: 5000 in the console log.
-
Raydar
I don't know why the daemon is accepting submissions from xmrig, but complaining about the proof of work from the demo miner.
-
Raydar
They are both pointing to the same endpoint. As far as I can tell they are both using the submit_block method in the same way. What is the difference there?
-
moneromooo
Did you miss the thing about endianness ?
-
Raydar
No, but I fear I don't really understand how to start with that. I thought jtgrassie was saying that the code from his github works as is and I was doing something wrong with the daemon settings.
-
Raydar
Using the logic to calculate the hash difficulty from the solo-block.py, I've noticed that the script calculates a hash difficulty above 5000 for the hashes it submits (which are not accepted)
-
Raydar
But when I use the same logic to calculate the difficulty from a hash that was accepted by the daemon, the calculated difficulty results in very low numbers (below 10 in my tests).
-
Raydar
Here's my example distilled from the solo-block.py with the valid and invalid hashes:
-
Raydar
import binascii
-
Raydar
# invalid example rejected by monerod- calculated hash difficulty = 5571
-
Raydar
#hash_str = "000bc35e8deda145ba1778918f96e2884caef790136a9f48812b6192724dbcc6"
-
Raydar
# valid example accepted by monerod - calculated hash difficulty = 1
-
Raydar
hash_str = "ee50e2a61515e0931fc6278b71936d28ac97561a032a831b1d865fd3f39b6351"
-
Raydar
# Calculate the base difficulty (2^256 - 1)
-
Raydar
base_diff = 2**256 - 1
-
Raydar
# Convert the hash string to an integer (big-endian)
-
Raydar
hash_int = int.from_bytes(binascii.unhexlify(hash_str), byteorder='big')
-
Raydar
# Calculate the hash difficulty
-
Raydar
hash_diff = base_diff / hash_int
-
Raydar
print(f"Hash Difficulty: {hash_diff}")