Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
0fbeb31d
Commit
0fbeb31d
authored
1 year ago
by
Francisco Gamundi
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
WasmExecutor flag to ignore onchain heappages value (#14508)
* WasmExecutor flag to ignore onchain heappages value * fmt
parent
1047f1fa
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/client/executor/src/executor.rs
+39
-12
39 additions, 12 deletions
substrate/client/executor/src/executor.rs
with
39 additions
and
12 deletions
substrate/client/executor/src/executor.rs
+
39
−
12
View file @
0fbeb31d
...
...
@@ -88,6 +88,7 @@ pub struct WasmExecutorBuilder<H> {
method
:
WasmExecutionMethod
,
onchain_heap_alloc_strategy
:
Option
<
HeapAllocStrategy
>
,
offchain_heap_alloc_strategy
:
Option
<
HeapAllocStrategy
>
,
ignore_onchain_heap_pages
:
bool
,
max_runtime_instances
:
usize
,
cache_path
:
Option
<
PathBuf
>
,
allow_missing_host_functions
:
bool
,
...
...
@@ -104,6 +105,7 @@ impl<H> WasmExecutorBuilder<H> {
method
:
WasmExecutionMethod
::
default
(),
onchain_heap_alloc_strategy
:
None
,
offchain_heap_alloc_strategy
:
None
,
ignore_onchain_heap_pages
:
false
,
max_runtime_instances
:
2
,
runtime_cache_size
:
4
,
allow_missing_host_functions
:
false
,
...
...
@@ -137,6 +139,14 @@ impl<H> WasmExecutorBuilder<H> {
self
}
/// Create the wasm executor and follow/ignore onchain heap pages value.
///
/// By default this the onchain heap pages value is followed.
pub
fn
with_ignore_onchain_heap_pages
(
mut
self
,
ignore_onchain_heap_pages
:
bool
)
->
Self
{
self
.ignore_onchain_heap_pages
=
ignore_onchain_heap_pages
;
self
}
/// Create the wasm executor with the given maximum number of `instances`.
///
/// The number of `instances` defines how many different instances of a runtime the cache is
...
...
@@ -193,6 +203,7 @@ impl<H> WasmExecutorBuilder<H> {
default_onchain_heap_alloc_strategy
:
unwrap_heap_pages
(
self
.onchain_heap_alloc_strategy
,
),
ignore_onchain_heap_pages
:
self
.ignore_onchain_heap_pages
,
cache
:
Arc
::
new
(
RuntimeCache
::
new
(
self
.max_runtime_instances
,
self
.cache_path
.clone
(),
...
...
@@ -214,6 +225,8 @@ pub struct WasmExecutor<H> {
default_onchain_heap_alloc_strategy
:
HeapAllocStrategy
,
/// The heap allocation strategy for offchain Wasm calls.
default_offchain_heap_alloc_strategy
:
HeapAllocStrategy
,
/// Ignore onchain heap pages value.
ignore_onchain_heap_pages
:
bool
,
/// WASM runtime cache.
cache
:
Arc
<
RuntimeCache
>
,
/// The path to a directory which the executor can leverage for a file cache, e.g. put there
...
...
@@ -230,6 +243,7 @@ impl<H> Clone for WasmExecutor<H> {
method
:
self
.method
,
default_onchain_heap_alloc_strategy
:
self
.default_onchain_heap_alloc_strategy
,
default_offchain_heap_alloc_strategy
:
self
.default_offchain_heap_alloc_strategy
,
ignore_onchain_heap_pages
:
self
.ignore_onchain_heap_pages
,
cache
:
self
.cache
.clone
(),
cache_path
:
self
.cache_path
.clone
(),
allow_missing_host_functions
:
self
.allow_missing_host_functions
,
...
...
@@ -276,6 +290,7 @@ where
default_offchain_heap_alloc_strategy
:
unwrap_heap_pages
(
default_heap_pages
.map
(|
h
|
HeapAllocStrategy
::
Static
{
extra_pages
:
h
as
_
}),
),
ignore_onchain_heap_pages
:
false
,
cache
:
Arc
::
new
(
RuntimeCache
::
new
(
max_runtime_instances
,
cache_path
.clone
(),
...
...
@@ -486,10 +501,14 @@ where
"Executing function"
,
);
let
on_chain_heap_alloc_strategy
=
runtime_code
.heap_pages
.map
(|
h
|
HeapAllocStrategy
::
Static
{
extra_pages
:
h
as
_
})
.unwrap_or_else
(||
self
.default_onchain_heap_alloc_strategy
);
let
on_chain_heap_alloc_strategy
=
if
self
.ignore_onchain_heap_pages
{
self
.default_onchain_heap_alloc_strategy
}
else
{
runtime_code
.heap_pages
.map
(|
h
|
HeapAllocStrategy
::
Static
{
extra_pages
:
h
as
_
})
.unwrap_or_else
(||
self
.default_onchain_heap_alloc_strategy
)
};
let
heap_alloc_strategy
=
match
context
{
CallContext
::
Offchain
=>
self
.default_offchain_heap_alloc_strategy
,
...
...
@@ -518,10 +537,14 @@ where
ext
:
&
mut
dyn
Externalities
,
runtime_code
:
&
RuntimeCode
,
)
->
Result
<
RuntimeVersion
>
{
let
on_chain_heap_pages
=
runtime_code
.heap_pages
.map
(|
h
|
HeapAllocStrategy
::
Static
{
extra_pages
:
h
as
_
})
.unwrap_or_else
(||
self
.default_onchain_heap_alloc_strategy
);
let
on_chain_heap_pages
=
if
self
.ignore_onchain_heap_pages
{
self
.default_onchain_heap_alloc_strategy
}
else
{
runtime_code
.heap_pages
.map
(|
h
|
HeapAllocStrategy
::
Static
{
extra_pages
:
h
as
_
})
.unwrap_or_else
(||
self
.default_onchain_heap_alloc_strategy
)
};
self
.with_instance
(
runtime_code
,
...
...
@@ -631,10 +654,14 @@ impl<D: NativeExecutionDispatch + 'static> CodeExecutor for NativeElseWasmExecut
"Executing function"
,
);
let
on_chain_heap_alloc_strategy
=
runtime_code
.heap_pages
.map
(|
h
|
HeapAllocStrategy
::
Static
{
extra_pages
:
h
as
_
})
.unwrap_or_else
(||
self
.wasm.default_onchain_heap_alloc_strategy
);
let
on_chain_heap_alloc_strategy
=
if
self
.wasm.ignore_onchain_heap_pages
{
self
.wasm.default_onchain_heap_alloc_strategy
}
else
{
runtime_code
.heap_pages
.map
(|
h
|
HeapAllocStrategy
::
Static
{
extra_pages
:
h
as
_
})
.unwrap_or_else
(||
self
.wasm.default_onchain_heap_alloc_strategy
)
};
let
heap_alloc_strategy
=
match
context
{
CallContext
::
Offchain
=>
self
.wasm.default_offchain_heap_alloc_strategy
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment