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

ChainStateView::execute_block can now activate a chain. #2379

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

afck
Copy link
Contributor

@afck afck commented Aug 15, 2024

Motivation

The linera-sdk TestValidator directly calls execute_block, without first handling the immediate message. That currently fails if it's the first block of a new child chain, because it has not been initialized yet.

Proposal

In execute_block, if it's block 0 of a child chain and the first message is OpenChain, execute that message before doing anything that requires the chain to be active.

Test Plan

CI should catch any regressions.
The feature itself was tested locally and will be used soon when the hex-game is extended to automatically create temporary chains.

Links

return Err(ChainError::InactiveChain(chain_id));
};
let Some(posted_message) = in_bundle.bundle.messages.first().filter(|pm| {
println!("{:#?}", pm.message);
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this println! should be removed? (Or replaced with trace!?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, too much debugging today! 🤦

.map_or(true, |description| description.is_child())
{
ensure!(
block.starts_with_open_chain(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this helper method still used after this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I'll remove it!

@afck afck merged commit 5e0f23c into linera-io:main Aug 15, 2024
4 checks passed
@afck afck deleted the execute-block-open-chain branch August 15, 2024 15:56
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.

2 participants