Loading contract bug
BUG FIX
Description of Bug and Fix
If siad is interrupted while writing a merkle root to disk, loading the contract file after restarting siad might result in an error due to the file not having the correct length.
This MR truncates the file before loading it if it doesn't have the correct length and returns a boolean to indicate that the loaded file was corrupted and might therefore be missing updates. If that boolean is true
, loadSafeContract
will apply the unapplied wal transactions to fix potential corruption.
Testing Added
TestContractIncompleteWrite
- Forces a corruption of the file and tries to reload it afterwards
Proof of Fix (ie Screenshot if applicable)
The reproduction test is passing.