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: RUN-1038: Propagate execution mode (wasm64/32) to replica #1784

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

alexandru-uta
Copy link
Contributor

@alexandru-uta alexandru-uta commented Oct 1, 2024

This PR adds functionality to make the replica aware of the Wasm32/Wasm64 execution mode of canisters. This will be used during the execution phase to track cycle consumption separately.

To have this, the canister execution state adds a is_wasm64 flag. This flag is computed by the compiler sandbox the first time a canister is installed, or when it is upgraded.

@github-actions github-actions bot added the feat label Oct 1, 2024
Copy link
Member

@fspreiss fspreiss left a comment

Choose a reason for hiding this comment

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

Changes in rs/test_utilities/state/src/lib.rs LGTM

)
}
}

impl ExecutionState {
pub fn new_for_testing(
Copy link
Member

Choose a reason for hiding this comment

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

Optional simplification: Since we have a new_for_testing function now, we could skip some of the arguments here and generate a default value in the function body. For some of these fields all the tests set them to some arbitrary value anyway. It definitely applies to canister_root, but might also apply to some of the other fields.

Copy link
Contributor

@adambratschikaye adambratschikaye left a comment

Choose a reason for hiding this comment

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

Nice. Just left some style comments.

Comment on lines +55 to 56
use ic_replicated_state::canister_state::execution_state::NextScheduledMethod;
use ic_replicated_state::page_map::PageAllocatorFileDescriptor;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: merge the imports here and in other locations?

Comment on lines +564 to +566
last_executed_round: ExecutionRound,
next_scheduled_method: NextScheduledMethod,
is_wasm64: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure we need to add the last_executed_round and next_scheduled_method arguments here? Maybe we could just default is_wasm64 to false and keep the other arguments the same. Then we wouldn't need to introduce the for_testing version and could remove some of the other changes in the PR.

When creating the execution state in wasm_executor.rs we could mutate the field to get the correct value or just create this struct directly without using the new method.

Comment on lines +7853 to +7857
let mut test = if is_wasm64 {
ExecutionTestBuilder::new().with_wasm64().build()
} else {
ExecutionTestBuilder::new().build()
};
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want the feature enabled even when testing the 32-bit memory, right? We want to show we properly detect 32-bit Wasms when the feature is enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants