Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: panic: Invalid Major Version in Block #154

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

8lecramm
Copy link
Contributor

@8lecramm 8lecramm commented Jan 20, 2024

Description

In rare cases (e.g. after power outage), the daemon cannot load the chain properly and panics.

...
20/01 22:09:43  INFO    RPC     RPC will listen {"address": "127.0.0.1:10102"}
20/01 22:09:43  INFO    GETWORK GETWORK will listen     {"address": "0.0.0.0:10100"}
panic: Invalid Major Version in Block

goroutine 1 [running]:
github.com/deroproject/derohe/blockchain.(*Blockchain).Load_Block_Timestamp(0x0?, {0xe, 0x73, 0xbc, 0xf, 0xbe, 0xb8, 0xed, 0x1b, 0x2d, ...})
        /home/marcel/go/src/derohe/blockchain/store.go:179 +0x51
github.com/deroproject/derohe/blockchain.Get_Difficulty_At_Tips({0xd317e0, 0xc000256000?}, {0xc0002e4020, 0x1, 0x1?})
        /home/marcel/go/src/derohe/blockchain/difficulty.go:239 +0x4d8
github.com/deroproject/derohe/blockchain.(*Blockchain).Get_Difficulty_At_Tips(0xc000256000, {0xc0002e4020, 0x1, 0x1})
        /home/marcel/go/src/derohe/blockchain/difficulty.go:146 +0x2d1
github.com/deroproject/derohe/blockchain.(*Blockchain).Get_Difficulty(0xc000256000)
        /home/marcel/go/src/derohe/blockchain/blockchain.go:1321 +0x125
github.com/deroproject/derohe/blockchain.(*Blockchain).Get_Network_HashRate(...)
        /home/marcel/go/src/derohe/blockchain/blockchain.go:1325
main.main()
        /home/marcel/go/src/derohe/cmd/derod/main.go:542 +0x1c52

The reason is empty block files.
This fix checks the top height for corruption and, in case of an error, rewinds a block.

Type of change

Please select the right one.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This will require a HardFork to be enabled

Which part is impacted ?

  • Wallet
  • Daemon
  • Miner
  • Explorer
  • Simulator
  • Misc (documentation, comments, text...)

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

License

I'm am contributing & releasing the code under DERO Research License (which can be found here).

@8lecramm 8lecramm changed the base branch from main to dev April 14, 2024 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant