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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
Duniter v2S
Commits
f038bce3
Commit
f038bce3
authored
2 years ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
embed raw chainspecs only when enabled
parent
81f4a877
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Cargo.toml
+2
-1
2 additions, 1 deletion
Cargo.toml
node/src/command.rs
+21
-21
21 additions, 21 deletions
node/src/command.rs
with
23 additions
and
22 deletions
Cargo.toml
+
2
−
1
View file @
f038bce3
...
...
@@ -19,9 +19,10 @@ path = "node/src/main.rs"
[features]
default
=
[
"gdev"
]
gdev
=
[
"gdev-runtime"
]
# gdev feature enables gdev runtime and gdev command line options
g1
=
[
"g1-runtime"
]
gdev
=
[
"gdev-runtime"
]
gtest
=
[
"gtest-runtime"
]
embed
=
[]
# embed feature enables embedding raw chainspecs that must be in ./specs/gdev-raw.json
runtime-benchmarks
=
[
#'g1-runtime',
#'g1-runtime/runtime-benchmarks',
...
...
This diff is collapsed.
Click to expand it.
node/src/command.rs
+
21
−
21
View file @
f038bce3
...
...
@@ -127,26 +127,31 @@ impl SubstrateCli for Cli {
#[cfg(feature
=
"gdev"
)]
"gdev-benchmark"
=>
Box
::
new
(
chain_spec
::
gdev
::
benchmark_chain_spec
()
?
),
// === GTEST ===
// dev chainspecs with Alice validator
//
generate
dev chainspecs with Alice validator
// provide DUNITER_GTEST_GENESIS env var if you want to build genesis from json
// otherwise you get a local testnet with generated genesis
#[cfg(feature
=
"gtest"
)]
"gtest_dev"
=>
Box
::
new
(
chain_spec
::
gtest
::
development_chainspecs
()
?
),
// chainspecs for live network
// must have following files in node/specs folder:
// - gtest.json
// - gtest_client-specs.json
// must have following files in
./
node/specs folder
or overwrite with env var
:
// - gtest.json
/ DUNITER_GTEST_GENESIS
// - gtest_client-specs.json
/ DUNITER_GTEST_CLIENT_SPEC
#[cfg(feature
=
"gtest"
)]
"gtest_live"
=>
{
const
JSON_CLIENT_SPEC
:
&
str
=
"./node/specs/gtest_client-specs.json"
;
const
JSON_GENESIS
:
&
str
=
"./node/specs/gtest_genesis.json"
;
let
client_spec
:
gtest
::
ClientSpec
=
serde_json
::
from_slice
(
&
std
::
fs
::
read
(
JSON_CLIENT_SPEC
)
&
std
::
fs
::
read
(
std
::
env
::
var
(
"DUNITER_GTEST_CLIENT_SPEC"
)
.unwrap_or
(
JSON_CLIENT_SPEC
.to_string
()),
)
.map_err
(|
e
|
format!
(
"failed to read {JSON_CLIENT_SPEC} {e}"
))
?
[
..
],
)
.map_err
(|
e
|
format!
(
"failed to parse {e}"
))
?
;
let
genesis_data
:
gtest_genesis
::
GenesisJson
=
serde_json
::
from_slice
(
&
std
::
fs
::
read
(
JSON_GENESIS
)
&
std
::
fs
::
read
(
std
::
env
::
var
(
"DUNITER_GTEST_GENESIS"
)
.unwrap_or
(
JSON_GENESIS
.to_string
()),
)
.map_err
(|
e
|
format!
(
"failed to read {JSON_GENESIS} {e}"
))
?
[
..
],
)
.map_err
(|
e
|
format!
(
"failed to parse {e}"
))
?
;
...
...
@@ -156,21 +161,16 @@ impl SubstrateCli for Cli {
genesis_data
,
)
?
)
}
// return hardcoded live chainspecs
// return hardcoded live chainspecs
, only with embed feature
// embed client spec and genesis to avoid embeding hexadecimal runtime
// and having hexadecimal runtime in git history
#[cfg(feature
=
"gtest"
)]
"gtest"
=>
{
let
client_spec
:
gtest
::
ClientSpec
=
serde_json
::
from_slice
(
include_bytes!
(
"../specs/gtest_client-specs.json"
))
.unwrap
();
let
genesis_data
:
gtest_genesis
::
GenesisJson
=
serde_json
::
from_slice
(
include_bytes!
(
"../specs/gtest_genesis.json"
))
.unwrap
();
Box
::
new
(
chain_spec
::
gtest
::
live_chainspecs
(
client_spec
,
genesis_data
,
)
?
)
}
// will only build on a branch that has a file
// ./node/specs/gtest-raw.json
#[cfg(all(feature
=
"gtest"
,
feature
=
"embed"
))]
"gtest"
=>
Box
::
new
(
chain_spec
::
gtest
::
ChainSpec
::
from_json_bytes
(
&
include_bytes!
(
"../specs/gtest-raw.json"
)[
..
],
)
?
),
// === G1 ===
#[cfg(feature
=
"g1"
)]
"g1"
=>
{
...
...
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