Polkadot-Blockchain-Academy / Academy-PoW

PoW blockchain node to gain hands-on experience starting a real network together
The Unlicense
21 stars 42 forks source link

Multi-pow #30

Closed JoshOrndorff closed 11 months ago

JoshOrndorff commented 1 year ago

This PR modifies the PoW consensus algorithm to support three valid hashing algorithms (md5, sha3, keccak) as opposed to just sha3 as before.

Motivation: Forking exercises

After academy students launch the chain together, we will experiment with forks. Both hard and soft forks. This will be accomplished by modifying the node to add or remove hashing algorithms from the set that it considers valid.

(@Overkillus I'd love your review on this.)

Cli Changes

It adds a cli flag --mining-algo which specifies which mining algorithm the node should use.

It also makes specifying a mining rewards identity optional, defaulting to the zero address.

Followup: Difficulty adjustment

One thing that I have not yet implemented is three independent difficulty adjustment algorithms. Currently the runtime doesn't actually know what work it gets as input at all, let alone which algorithm that work came from. My idea is that I could add a pre-runtime digest to the block that passes in the algorithm, then it can be checked that the seal really is for the same algorithm. This can probably be tackled in a followup.