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

feat!: dedicated security error code for ongoing fork #583

Closed

Conversation

gregdhill
Copy link
Member

Signed-off-by: Gregory Hill gregorydhill@outlook.com

Closes #565

Signed-off-by: Gregory Hill <gregorydhill@outlook.com>
@gregdhill gregdhill requested a review from sander2 May 10, 2022 11:46
@@ -15,4 +16,13 @@ pub(crate) mod security {
) -> Result<bool, DispatchError> {
<security::Pallet<T>>::parachain_block_expired(opentime, period)
}

pub fn insert_ongoing_fork_error<T: crate::Config>() {
<security::Pallet<T>>::set_status(StatusCode::Error);
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible for the parachain to be in shutdown when this happens? If not, please add a comment somewhere to that effect

@@ -535,6 +539,7 @@ impl<T: Config> Pallet<T> {
// if we added a block to a fork, we may need to reorder the chains
Self::reorganize_chains(&blockchain)?;
} else {
Self::update_no_ongoing_fork(current_block_height)?;
Copy link
Member

Choose a reason for hiding this comment

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

I think this code path can be taken even when there is a fork ahead of the mainchain (since I think reordering is not done until a fork gets 6 blocks ahead). If that is the case, this update_no_ongoing_fork is incorrect.

This PR looks like a simple change, but the bitcoin code is deceptively complex and error prone. I would like to see more tests, including for the scenario above. Additionally, I would like to have a check that the error status is equal to the output of ensure_no_ongoing_fork in check_store_block_header_invariants

@gregdhill
Copy link
Member Author

Superseded by #1119 - the error type was removed. We should update downstream systems to determine transaction validity some other way, possibly by dry running first.

@gregdhill gregdhill closed this Jul 18, 2023
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.

Add dedicated security error for OngoingFork
2 participants