-
Notifications
You must be signed in to change notification settings - Fork 707
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
How to bring back Native execution on my chain? #2891
Comments
The problem is that native is not guaranteed to be deterministic like WASM. I think there were a few MRs about this from @michalkucharczyk. What kind of performance degradation do you see? Did you compile with |
Yeah, please provide some numbers. For sure wasm is slower, but it should be not that much slower. |
Here is a portion of my [profile.production]
inherits = "release"
codegen-units = 1 # Setting this to 1 allows for more optimizations at the cost of slower compile time
lto = true # Enables Link Time Optimization, enabling more aggressive optimizations across the entire codebase
opt-level = 3 # Optimize for speed regardless of binary size or compile time
rpath = false # Disables adding rpath to the binary
We are around 40 TPS in Wasm and if we revert back to We use Substrate to run a VM whose execution is provable and deterministic. So we already have this guarantee. |
Here is the list of relevant PRs I am aware of:
You meant wasm? |
What kind of VM? Maybe you could just run the VM in a host function. |
Here is the VM: https://github.com/lambdaclass/cairo-vm Host functions could be an idea. But the Blockifier has to access the storage too. |
Thanks for the links @michalkucharczyk ! |
If you're doing zk starks, then shouldn't you be using all custom storage, except for system paramaters, etc? |
Sorry, I don't understand the implications of your message. Can you explain a bit more what you mean? |
Yeah, then create some host function for it? |
@bkchr Can you share an example of something similar being achieved? Is it possible to write to the key value DB from such a host function? Is is written to the DB directly or to the cache? |
Depends how you implement it. Here is an example: polkadot-sdk/substrate/primitives/statement-store/src/runtime_api.rs Lines 120 to 187 in 9db9211
|
in fact for now you can still use NativeExecutor for now, only need to specify the NativeElseWasmExecutor in service.rs pub struct Executor;
impl NativeExecutionDispatch for Executor {
type ExtendHostFunctions = ();
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
node_template_runtime::api::dispatch(method, data)
}
fn native_version() -> NativeVersion {
node_template_runtime::native_version()
}
}
pub fn new_native_or_wasm_executor<D: NativeExecutionDispatch>(
config: &Configuration,
) -> NativeElseWasmExecutor<D> {
NativeElseWasmExecutor::new_with_wasm_executor(new_wasm_executor(config))
} this pr show more info for this ##2358, which comes from our team |
Hey,
I know native execution has been removed in a recent update. We can only execute in Wasm, which has a clear impact on my chain TPS.
I want to be able to execute in Native again. How can I have it back?
I think it is still there, somewhere in the codebase, because pallet's tests are still run in Native. So, is it as simple as tweaking a config or changing a bool somewhere, or will it require me to fork Substrate? If I have to fork, could you point me to where is the code I have to change?
Also, I would like to know the exact PR that removed Native execution. It will probably be helpful in my endeavors.
Best regards
The text was updated successfully, but these errors were encountered: