harmony-one / horizon

Horizon - a trustless harmony to ethereum bridge
MIT License
36 stars 29 forks source link

Handle forking, track canonical chain #31

Closed brucdarc closed 2 years ago

brucdarc commented 2 years ago

Closes #19

Keeps track of the canonical chain using total difficulty, the current fork choice metric for the eth mainnet. Does not keep track of forks other than the canonical chain, instead replaces the canonical chain.

Also I think we should consider removing the verifiedBlocks and finalizedBlocks mappings, and replacing them with view functions that calculate how many confirmations a block on the canonical chain has from the canonical head.

brucdarc commented 2 years ago

Refactored verified and finalized blocks into view functions based on confirmations. Let me know how many confirmations seem good for this purpose.

brucdarc commented 2 years ago

Ready for review, canonical chain tracking along with testing for canonical chain. Implemented test contract folder, where test contracts can inherit main contracts to expose extra testing functionality. Also includes a couple fixes to the environment/cli. I recommend squashing commits before merging because I have a good few here.

polymorpher commented 2 years ago

This should be mergable pending test result reproduction @gupadhyaya

gupadhyaya commented 2 years ago

@brucdarc can you resolve the merge conflicts?

brucdarc commented 2 years ago

@brucdarc can you resolve the merge conflicts?

Done