Skip to content

Conversation

spoonincode
Copy link
Member

Prior to leap 3.2, when writing a state history log entry with a block number less than the log's head block number, the log would be truncated to the new lower block number (truncated as in the file's contents are removed entirely).

This behavior allowed an accidental erasure of the entire state history log (see AntelopeIO/leap#659), so in leap 3.2 (AntelopeIO/leap#737) the behavior was modified: writing the genesis block in to a non empty state history log was immediately assert failure, and writing any other blocks in to the log would only truncate the log if the blockid is different; otherwise the logs were left unaltered.

But that change has a side effect that makes it impossible to replay a chain from genesis while keeping the state history logs intact (see #413). So instead, modify behavior such that writing any existing block -- even the genesis block -- with the same blockid is treated as a "no-op" (logs left unaltered), and disallowing rewriting the genesis block with a different blockid.

Resolves #413

std::string err = e.to_detail_string();
return err.find("existing ship log") != std::string::npos && err.find("when starting from genesis block") != std::string::npos;
});

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's okay to remove this particular check: the test case is actually for pruned logs and pruned logs for this test case won't have the genesis block anyways. The test worked previously because the blocknum==2 check was so early in the logic.

The test case further down exercises the genesis block behavior.

@ericpassmore
Copy link
Contributor

Note:start
group: STABILITY
category: INTERNALS
summary: Allow replaying a chain from genesis while keeping the state history logs intact.
Note:end

@spoonincode spoonincode merged commit 829ddd5 into main Aug 8, 2024
36 checks passed
@spoonincode spoonincode deleted the shiplog_noop_identical_genesis branch August 8, 2024 22:18
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.

SHiP write error when using --replay-blockchain
4 participants