EVM/Kernel: the Kernel owns the runtime
What
This MR aims to solve a particular issue we have since !14810 (merged) has been merged: using the MockHost is a bit annoying. To solve that, we change the entrypoint of the kernel to not use the macro from the SDK and inline it, so that the main kernel loop owns the runtime instead of getting a mutable reference.
Why and how
Basically the current situation is that it is impossible to produce easily a MockHost, as KernelHost contains a mutable reference to the Host. You cannot write such a function :
fn mock() -> KernelHost {
KernelHost { host : &mut MockHost::default, internal: &mut MockInternal() }
}
as MockHost and MockInternal are allocated by the function and would escape the scope of the function as reference.
This type is unfortunately due to the entrypoint that gives the host as a mutable reference.
The solution is to simply not use the macro and inline it, then we can implement a KernelHost that owns the Runtime.
Manually testing the MR
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR