Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
nodes
rust
Duniter v2S
Commits
949716be
Commit
949716be
authored
1 year ago
by
bgallois
Committed by
Hugo Trentesaux
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor executor
parent
07bb8814
No related branches found
No related tags found
1 merge request
!256
Refactor node implementation
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
node/src/command.rs
+12
-20
12 additions, 20 deletions
node/src/command.rs
node/src/service.rs
+15
-77
15 additions, 77 deletions
node/src/service.rs
node/src/service/client.rs
+12
-14
12 additions, 14 deletions
node/src/service/client.rs
with
39 additions
and
111 deletions
node/src/command.rs
+
12
−
20
View file @
949716be
...
...
@@ -23,12 +23,7 @@ pub mod utils;
#[cfg(feature
=
"gtest"
)]
use
crate
::
chain_spec
::
gtest
;
use
crate
::
cli
::{
Cli
,
Subcommand
};
#[cfg(feature
=
"g1"
)]
use
crate
::
service
::
g1_executor
::
G1Executor
;
#[cfg(feature
=
"gdev"
)]
use
crate
::
service
::
gdev_executor
::
GDevExecutor
;
#[cfg(feature
=
"gtest"
)]
use
crate
::
service
::
gtest_executor
::
GTestExecutor
;
use
crate
::
service
::
runtime_executor
::
Executor
;
use
crate
::
service
::{
IdentifyRuntimeType
,
RuntimeType
};
use
crate
::{
chain_spec
,
service
};
use
clap
::
CommandFactory
;
...
...
@@ -351,21 +346,21 @@ pub fn run() -> sc_cli::Result<()> {
RuntimeType
::
G1
=>
runner
.sync_run
(|
config
|
{
cmd
.run
::
<
g1_runtime
::
Block
,
ExtendedHostFunctions
<
sp_io
::
SubstrateHostFunctions
,
<
G1
Executor
as
NativeExecutionDispatch
>
::
ExtendHostFunctions
,
<
Executor
as
NativeExecutionDispatch
>
::
ExtendHostFunctions
,
>>
(
config
)
}),
#[cfg(feature
=
"gtest"
)]
RuntimeType
::
GTest
=>
runner
.sync_run
(|
config
|
{
cmd
.run
::
<
gtest_runtime
::
Block
,
ExtendedHostFunctions
<
sp_io
::
SubstrateHostFunctions
,
<
GTest
Executor
as
NativeExecutionDispatch
>
::
ExtendHostFunctions
,
<
Executor
as
NativeExecutionDispatch
>
::
ExtendHostFunctions
,
>>
(
config
)
}),
#[cfg(feature
=
"gdev"
)]
RuntimeType
::
GDev
=>
runner
.sync_run
(|
config
|
{
cmd
.run
::
<
gdev_runtime
::
Block
,
ExtendedHostFunctions
<
sp_io
::
SubstrateHostFunctions
,
<
GDev
Executor
as
NativeExecutionDispatch
>
::
ExtendHostFunctions
,
<
Executor
as
NativeExecutionDispatch
>
::
ExtendHostFunctions
,
>>
(
config
)
}),
_
=>
Err
(
sc_cli
::
Error
::
Application
(
"unknown runtime type"
.into
())),
...
...
@@ -420,7 +415,7 @@ pub fn run() -> sc_cli::Result<()> {
//sp_core::crypto::set_default_ss58_version(Ss58AddressFormatRegistry::GDev);
runner
.async_run
(|
config
|
{
Ok
((
cmd
.run
::
<
gdev_runtime
::
Block
,
GDev
Executor
>
(
config
),
cmd
.run
::
<
gdev_runtime
::
Block
,
Executor
>
(
config
),
task_manager
,
))
})
...
...
@@ -444,22 +439,19 @@ pub fn run() -> sc_cli::Result<()> {
match
config
.chain_spec
.runtime_type
()
{
#[cfg(feature
=
"g1"
)]
RuntimeType
::
G1
=>
{
service
::
new_full
::
<
g1_runtime
::
RuntimeApi
,
G1
Executor
>
(
config
,
cli
.sealing
)
service
::
new_full
::
<
g1_runtime
::
RuntimeApi
,
Executor
>
(
config
,
cli
.sealing
)
.map_err
(
sc_cli
::
Error
::
Service
)
}
#[cfg(feature
=
"gtest"
)]
RuntimeType
::
GTest
=>
service
::
new_full
::
<
gtest_runtime
::
RuntimeApi
,
GTestExecutor
,
>
(
config
,
cli
.sealing
)
RuntimeType
::
GTest
=>
service
::
new_full
::
<
gtest_runtime
::
RuntimeApi
,
Executor
>
(
config
,
cli
.sealing
,
)
.map_err
(
sc_cli
::
Error
::
Service
),
#[cfg(feature
=
"gdev"
)]
RuntimeType
::
GDev
=>
{
service
::
new_full
::
<
gdev_runtime
::
RuntimeApi
,
GDevExecutor
>
(
config
,
cli
.sealing
,
)
.map_err
(
sc_cli
::
Error
::
Service
)
service
::
new_full
::
<
gdev_runtime
::
RuntimeApi
,
Executor
>
(
config
,
cli
.sealing
)
.map_err
(
sc_cli
::
Error
::
Service
)
}
_
=>
Err
(
sc_cli
::
Error
::
Application
(
"unknown runtime"
.into
())),
}
...
...
This diff is collapsed.
Click to expand it.
node/src/service.rs
+
15
−
77
View file @
949716be
...
...
@@ -54,91 +54,29 @@ type FullClient<RuntimeApi, Executor> =
type
FullBackend
=
sc_service
::
TFullBackend
<
Block
>
;
type
FullSelectChain
=
sc_consensus
::
LongestChain
<
FullBackend
,
Block
>
;
#[cfg(feature
=
"gdev"
)]
pub
mod
gdev_executor
{
pub
mod
runtime_executor
{
use
crate
::
service
::
HostFunctions
;
pub
use
gdev_runtime
;
#[cfg(feature
=
"g1"
)]
pub
use
g1_runtime
as
runtime
;
#[cfg(feature
=
"gdev"
)]
pub
use
gdev_runtime
as
runtime
;
#[cfg(feature
=
"gtest"
)]
pub
use
gtest_runtime
as
runtime
;
use
sc_executor
::
sp_wasm_interface
::{
Function
,
HostFunctionRegistry
};
pub
struct
GDev
Executor
;
impl
sc_executor
::
NativeExecutionDispatch
for
GDev
Executor
{
pub
struct
Executor
;
impl
sc_executor
::
NativeExecutionDispatch
for
Executor
{
type
ExtendHostFunctions
=
frame_benchmarking
::
benchmarking
::
HostFunctions
;
fn
dispatch
(
method
:
&
str
,
data
:
&
[
u8
])
->
Option
<
Vec
<
u8
>>
{
gdev_
runtime
::
api
::
dispatch
(
method
,
data
)
runtime
::
api
::
dispatch
(
method
,
data
)
}
fn
native_version
()
->
sc_executor
::
NativeVersion
{
gdev_
runtime
::
native_version
()
runtime
::
native_version
()
}
}
impl
sc_executor
::
sp_wasm_interface
::
HostFunctions
for
GDevExecutor
{
fn
host_functions
()
->
Vec
<&
'static
dyn
Function
>
{
HostFunctions
::
host_functions
()
}
fn
register_static
<
T
>
(
registry
:
&
mut
T
)
->
Result
<
(),
T
::
Error
>
where
T
:
HostFunctionRegistry
,
{
HostFunctions
::
register_static
(
registry
)
}
}
}
#[allow(dead_code)]
#[cfg(feature
=
"g1"
)]
pub
mod
g1_executor
{
use
crate
::
service
::
HostFunctions
;
pub
use
g1_runtime
;
use
sc_executor
::
sp_wasm_interface
::{
Function
,
HostFunctionRegistry
};
pub
struct
G1Executor
;
impl
sc_executor
::
NativeExecutionDispatch
for
G1Executor
{
type
ExtendHostFunctions
=
frame_benchmarking
::
benchmarking
::
HostFunctions
;
fn
dispatch
(
method
:
&
str
,
data
:
&
[
u8
])
->
Option
<
Vec
<
u8
>>
{
g1_runtime
::
api
::
dispatch
(
method
,
data
)
}
fn
native_version
()
->
sc_executor
::
NativeVersion
{
g1_runtime
::
native_version
()
}
}
impl
sc_executor
::
sp_wasm_interface
::
HostFunctions
for
G1Executor
{
fn
host_functions
()
->
Vec
<&
'static
dyn
Function
>
{
HostFunctions
::
host_functions
()
}
fn
register_static
<
T
>
(
registry
:
&
mut
T
)
->
Result
<
(),
T
::
Error
>
where
T
:
HostFunctionRegistry
,
{
HostFunctions
::
register_static
(
registry
)
}
}
}
#[allow(dead_code)]
#[cfg(feature
=
"gtest"
)]
pub
mod
gtest_executor
{
use
crate
::
service
::
HostFunctions
;
pub
use
gtest_runtime
;
use
sc_executor
::
sp_wasm_interface
::{
Function
,
HostFunctionRegistry
};
pub
struct
GTestExecutor
;
impl
sc_executor
::
NativeExecutionDispatch
for
GTestExecutor
{
type
ExtendHostFunctions
=
frame_benchmarking
::
benchmarking
::
HostFunctions
;
fn
dispatch
(
method
:
&
str
,
data
:
&
[
u8
])
->
Option
<
Vec
<
u8
>>
{
gtest_runtime
::
api
::
dispatch
(
method
,
data
)
}
fn
native_version
()
->
sc_executor
::
NativeVersion
{
gtest_runtime
::
native_version
()
}
}
impl
sc_executor
::
sp_wasm_interface
::
HostFunctions
for
GTestExecutor
{
impl
sc_executor
::
sp_wasm_interface
::
HostFunctions
for
Executor
{
fn
host_functions
()
->
Vec
<&
'static
dyn
Function
>
{
HostFunctions
::
host_functions
()
}
...
...
@@ -207,7 +145,7 @@ pub fn new_chain_ops(
import_queue
,
task_manager
,
..
}
=
new_partial
::
<
g1_runtime
::
RuntimeApi
,
g1
_executor
::
G1Executor
>
(
}
=
new_partial
::
<
g1_runtime
::
RuntimeApi
,
runtime
_executor
::
G1Executor
>
(
config
,
manual_consensus
,
)
?
;
...
...
@@ -226,7 +164,7 @@ pub fn new_chain_ops(
import_queue
,
task_manager
,
..
}
=
new_partial
::
<
gtest_runtime
::
RuntimeApi
,
gtest
_executor
::
GTestExecutor
>
(
}
=
new_partial
::
<
gtest_runtime
::
RuntimeApi
,
runtime
_executor
::
GTestExecutor
>
(
config
,
manual_consensus
,
)
?
;
...
...
@@ -245,7 +183,7 @@ pub fn new_chain_ops(
import_queue
,
task_manager
,
..
}
=
new_partial
::
<
gdev_runtime
::
RuntimeApi
,
gdev
_executor
::
GDev
Executor
>
(
}
=
new_partial
::
<
gdev_runtime
::
RuntimeApi
,
runtime
_executor
::
Executor
>
(
config
,
manual_consensus
,
)
?
;
...
...
This diff is collapsed.
Click to expand it.
node/src/service/client.rs
+
12
−
14
View file @
949716be
...
...
@@ -146,11 +146,11 @@ impl<Api> RuntimeApiCollection for Api where
#[derive(Clone)]
pub
enum
Client
{
#[cfg(feature
=
"g1"
)]
G1
(
Arc
<
super
::
FullClient
<
g1_runtime
::
RuntimeApi
,
super
::
g1
_executor
::
G1
Executor
>>
),
G1
(
Arc
<
super
::
FullClient
<
g1_runtime
::
RuntimeApi
,
super
::
runtime
_executor
::
Executor
>>
),
#[cfg(feature
=
"gtest"
)]
GTest
(
Arc
<
super
::
FullClient
<
gtest_runtime
::
RuntimeApi
,
super
::
gtest
_executor
::
GTest
Executor
>>
),
GTest
(
Arc
<
super
::
FullClient
<
gtest_runtime
::
RuntimeApi
,
super
::
runtime
_executor
::
Executor
>>
),
#[cfg(feature
=
"gdev"
)]
GDev
(
Arc
<
super
::
FullClient
<
gdev_runtime
::
RuntimeApi
,
super
::
gdev
_executor
::
GDev
Executor
>>
),
GDev
(
Arc
<
super
::
FullClient
<
gdev_runtime
::
RuntimeApi
,
super
::
runtime
_executor
::
Executor
>>
),
}
macro_rules!
with_client
{
...
...
@@ -197,23 +197,23 @@ impl ClientHandle for Client {
}
#[cfg(feature
=
"g1"
)]
impl
From
<
Arc
<
super
::
FullClient
<
g1_runtime
::
RuntimeApi
,
super
::
g1
_executor
::
G1
Executor
>>>
impl
From
<
Arc
<
super
::
FullClient
<
g1_runtime
::
RuntimeApi
,
super
::
runtime
_executor
::
Executor
>>>
for
Client
{
fn
from
(
client
:
Arc
<
super
::
FullClient
<
g1_runtime
::
RuntimeApi
,
super
::
g1
_executor
::
G1
Executor
>>
,
client
:
Arc
<
super
::
FullClient
<
g1_runtime
::
RuntimeApi
,
super
::
runtime
_executor
::
Executor
>>
,
)
->
Self
{
Self
::
G1
(
client
)
}
}
#[cfg(feature
=
"gtest"
)]
impl
From
<
Arc
<
super
::
FullClient
<
gtest_runtime
::
RuntimeApi
,
super
::
gtest
_executor
::
GTest
Executor
>>>
impl
From
<
Arc
<
super
::
FullClient
<
gtest_runtime
::
RuntimeApi
,
super
::
runtime
_executor
::
Executor
>>>
for
Client
{
fn
from
(
client
:
Arc
<
super
::
FullClient
<
gtest_runtime
::
RuntimeApi
,
super
::
gtest
_executor
::
GTest
Executor
>
,
super
::
FullClient
<
gtest_runtime
::
RuntimeApi
,
super
::
runtime
_executor
::
Executor
>
,
>
,
)
->
Self
{
Self
::
GTest
(
client
)
...
...
@@ -221,13 +221,11 @@ impl From<Arc<super::FullClient<gtest_runtime::RuntimeApi, super::gtest_executor
}
#[cfg(feature
=
"gdev"
)]
impl
From
<
Arc
<
super
::
FullClient
<
gdev_runtime
::
RuntimeApi
,
super
::
gdev
_executor
::
GDev
Executor
>>>
impl
From
<
Arc
<
super
::
FullClient
<
gdev_runtime
::
RuntimeApi
,
super
::
runtime
_executor
::
Executor
>>>
for
Client
{
fn
from
(
client
:
Arc
<
super
::
FullClient
<
gdev_runtime
::
RuntimeApi
,
super
::
gdev_executor
::
GDevExecutor
>
,
>
,
client
:
Arc
<
super
::
FullClient
<
gdev_runtime
::
RuntimeApi
,
super
::
runtime_executor
::
Executor
>>
,
)
->
Self
{
Self
::
GDev
(
client
)
}
...
...
@@ -328,15 +326,15 @@ trait BenchmarkCallSigner<RuntimeCall: Encode + Clone, Signer: Pair> {
#[cfg(feature
=
"g1"
)]
use
g1_runtime
as
runtime
;
#[cfg(feature
=
"g1"
)]
type
FullClient
=
super
::
FullClient
<
runtime
::
RuntimeApi
,
super
::
g1
_executor
::
G1
Executor
>
;
type
FullClient
=
super
::
FullClient
<
runtime
::
RuntimeApi
,
super
::
runtime
_executor
::
Executor
>
;
#[cfg(feature
=
"gdev"
)]
use
gdev_runtime
as
runtime
;
#[cfg(feature
=
"gdev"
)]
type
FullClient
=
super
::
FullClient
<
runtime
::
RuntimeApi
,
super
::
gdev
_executor
::
GDev
Executor
>
;
type
FullClient
=
super
::
FullClient
<
runtime
::
RuntimeApi
,
super
::
runtime
_executor
::
Executor
>
;
#[cfg(feature
=
"gtest"
)]
use
gtest_runtime
as
runtime
;
#[cfg(feature
=
"gtest"
)]
type
FullClient
=
super
::
FullClient
<
runtime
::
RuntimeApi
,
super
::
gtest
_executor
::
GTest
Executor
>
;
type
FullClient
=
super
::
FullClient
<
runtime
::
RuntimeApi
,
super
::
runtime
_executor
::
Executor
>
;
#[cfg(any(feature
=
"gdev"
,
feature
=
"gtest"
))]
impl
BenchmarkCallSigner
<
runtime
::
RuntimeCall
,
sp_core
::
sr25519
::
Pair
>
for
FullClient
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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