stakecube / StakeCubeCoin

StakeCube Coin (SCC) Blockchain & Core Wallets
https://stakecubecoin.net
MIT License
22 stars 10 forks source link

Validation error on mix_hash check #31

Open squidicuzz opened 1 year ago

squidicuzz commented 1 year ago

Block validation enhancement

Within validation.cpp at CChainState::ConnectBlock there used to contain a check for a valid mix_hash. This was removed earlier due to issues with prior launch of progpow and we would now like to return usage of this check for block validation. However; when the check is included once again, it causes the block(s) to be marked as invalid.

This check needs to be corrected and the mix_hash should equal the expected...

Tasks

Related Refs

Development Branch

Debug

TestNet

Invalid

2023-08-16T09:27:02Z [DEBUG] exp_mix_hash: e416f7f4ec9038f1d0758197025f3d51f1078665cb4649c0453dc907f6482e0e
2023-08-16T09:27:02Z [DEBUG] block.mix_hash: 0000000000000000000000000000000000000000000000000000000000000000
2023-08-16T09:27:02Z [DEBUG] final_hash: ee6332d7d219a71f59e27ae7016bb358f407ba0dbb63d13941454becf676864c
2023-08-16T09:27:02Z [DEBUG][WARN] CChainState::ConnectBlock: Accepted result as 'REJECT_INVALID' with 'invalid-mixhash' -- 'mix_hash validity failed' :: exp_mix_hash != block.mix_hash :: e416f7f4ec9038f1d0758197025f3d51f1078665cb4649c0453dc907f6482e0e != 0000000000000000000000000000000000000000000000000000000000000000

Valid

2023-08-16T09:31:57Z [DEBUG] exp_mix_hash: 8a2b022ed0acefb1d515853cba3d5c9f33da383736d1a4518cf676e17fa9b3af
2023-08-16T09:31:57Z [DEBUG] block.mix_hash: 8a2b022ed0acefb1d515853cba3d5c9f33da383736d1a4518cf676e17fa9b3af
2023-08-16T09:31:57Z [DEBUG] final_hash: 0000000007a7e52af13b15ca9bed8e241bdfcd2bb9821821846ece2e98951404

...

squidicuzz commented 1 year ago

debug outputs from testnet ... image

squidicuzz commented 1 year ago

Valid mix_hash is produced by miners who are using the correct epoch_length. Miners will need to update to use the correct epoch_length, and a check for this within the protocol will need to be enforced at some point in the future.