[substrate]cargo +nightly test error: the trait bound `__ink_ConstructorDecoder: parity_scale_codec::codec::WrapperTypeDecode` is not satisfied - substrate

Follow the step from the https://docs.substrate.io/tutorials/v3/ink-workshop/pt1/#creating-an-ink-project, when try to RUN:
cargo +nightly test
the compile show the error:
Compiling flipper v0.1.0 (/Users/x/Dev/flipper)
error[E0277]: the trait bound `__ink_ConstructorDecoder: parity_scale_codec::codec::WrapperTypeDecode` is not satisfied
--> lib.rs:8:5
|
8 | / /// Defines the storage of your contract.
9 | | /// Add new fields to the below struct in order
10 | | /// to add new static storage fields to your contract.
11 | | #[ink(storage)]
... |
14 | | value: bool,
15 | | }
| |_____^ the trait `parity_scale_codec::codec::WrapperTypeDecode` is not implemented for `__ink_ConstructorDecoder`
|
= note: required because of the requirements on the impl of `parity_scale_codec::codec::Decode` for `__ink_ConstructorDecoder`
note: required by a bound in `DecodeDispatch`
--> /Users/x/.cargo/registry/src/github.com-1ecc6299db9ec823/ink_lang-3.0.0-rc9/src/reflect/dispatch.rs:653:27
|
653 | pub trait DecodeDispatch: scale::Decode {
| ^^^^^^^^^^^^^ required by this bound in `DecodeDispatch`
Not sure how to fix this error ...

Related

Errors when installing substrate-validator-set

I'm trying to install the substrate-validator-set pallet but I'm getting this errors:
I'm trying to modify it to work but I can't get it working, I make a fork and tried to compile but it give me a bunch of errors, something like "expected ," ex:
error: expected `,`
--> /home/easy/.cargo/registry/src/github.com-1ecc6299db9ec823/js-sys-0.3.47/src/lib.rs:639:39
|
639 | #[wasm_bindgen(js_namespace = Atomics, catch)]
| ^^^^^^^
error: expected `,`
--> /home/easy/.cargo/registry/src/github.com-1ecc6299db9ec823/js-sys-0.3.47/src/lib.rs:1576:39
|
1576 | #[wasm_bindgen(js_namespace = Math)]
| ^^^^
error: expected `,`
--> /home/easy/.cargo/registry/src/github.com-1ecc6299db9ec823/js-sys-0.3.47/src/lib.rs:2832:39
|
2832 | #[wasm_bindgen(js_namespace = Reflect, js_name = getOwnPropertyDescriptor, catch)]
| ^^^^^^^
error[E0425]: cannot find function `get` in module `Reflect`
--> /home/easy/.cargo/registry/src/github.com-1ecc6299db9ec823/js-sys-0.3.47/src/lib.rs:1524:28
|
1524 | let iter_fn = Reflect::get(val, iter_sym.as_ref())?;
| ^^^ not found in `Reflect`
|
help: consider importing this function
|
21 | use std::rt::panic_count::get;
|
error[E0412]: cannot find type `Memory` in module `WebAssembly`
--> /home/easy/.cargo/registry/src/github.com-1ecc6299db9ec823/js-sys-0.3.47/src/lib.rs:4933:60
|
4933 | let mem = buf.unchecked_ref::<WebAssembly::Memory>();
| ^^^^^^ not found in `WebAssembly`
...
5008 | / arrays! {
5009 | | /// `Int8Array()`
5010 | | /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array
5011 | | Int8Array: i8,
... |
5043 | | Float64Array: f64,
5044 | | }
| |_- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0412]: cannot find type `Memory` in module `WebAssembly`
--> /home/easy/.cargo/registry/src/github.com-1ecc6299db9ec823/js-sys-0.3.47/src/lib.rs:4958:60
|
4958 | let mem = buf.unchecked_ref::<WebAssembly::Memory>();
| ^^^^^^ not found in `WebAssembly`
...
5008 | / arrays! {
5009 | | /// `Int8Array()`
5010 | | /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array
5011 | | Int8Array: i8,
... |
5043 | | Float64Array: f64,
5044 | | }
| |_- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0412]: cannot find type `Memory` in module `WebAssembly`
--> /home/easy/.cargo/registry/src/github.com-1ecc6299db9ec823/js-sys-0.3.47/src/lib.rs:4968:60
|
4968 | let mem = buf.unchecked_ref::<WebAssembly::Memory>();
| ^^^^^^ not found in `WebAssembly`
...
5008 | / arrays! {
5009 | | /// `Int8Array()`
5010 | | /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array
5011 | | Int8Array: i8,
... |
5043 | | Float64Array: f64,
5044 | | }
| |_- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 123 previous errors
Some errors have detailed explanations: E0412, E0425.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `js-sys`
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
How can I fix it?
You can try update wasm-bindgen (cargo update -p wasm-bindgen)

Build a PoE Decentralized Application Substrate Tutorial error: could not compile `sp-arithmetic`

I am following the Build a PoE decentralized application tutorial. I successfully completed the build your first substrate chain tutorial. I updated substrate to 2.0.1 and it made the first tutorial work perfectly. Now when I use 2.0.1, it fixed one of the error codes, but I still have some. Here is my log:
$ WASM_BUILD_TOOLCHAIN=nightly-2020-10-05 cargo run --release -- --dev --tmp
warning: TOML file found which contains invalid syntax and will soon not parse
at `pallets\template\Cargo.toml`.
The TOML spec requires that each table header is defined at most once, but
historical versions of Cargo have erroneously accepted this file. The table
definitions will need to be merged together with one table header to proceed,
and this will become a hard error in the future.
warning: TOML file found which contains invalid syntax and will soon not parse
at `pallets\template\Cargo.toml`.
The TOML spec requires that each table header is defined at most once, but
historical versions of Cargo have erroneously accepted this file. The table
definitions will need to be merged together with one table header to proceed,
and this will become a hard error in the future.
Compiling substrate-prometheus-endpoint v0.8.1
Compiling hyper-rustls v0.21.0
Compiling node-template-runtime v2.0.1 (C:\Users\matth\substrate-node-template\runtime)
Compiling libp2p-websocket v0.23.0
Compiling libp2p-mplex v0.22.0
Compiling libp2p-wasm-ext v0.22.0
Compiling libp2p-plaintext v0.22.0
Compiling libp2p-yamux v0.25.0
Compiling libp2p-dns v0.22.0
Compiling libp2p-noise v0.24.0
Compiling libp2p-tcp v0.22.0
Compiling libp2p-request-response v0.3.0
Compiling libp2p-ping v0.22.0
Compiling libp2p-identify v0.22.0
Compiling libp2p-kad v0.23.0
Compiling libp2p-mdns v0.22.0
Compiling libp2p-gossipsub v0.22.0
Compiling libp2p-floodsub v0.22.0
Compiling sc-proposer-metrics v0.8.1
Compiling sp-io v2.0.1
Compiling libp2p v0.28.1
Compiling sc-telemetry v2.0.1
Compiling sc-peerset v2.0.1
Compiling sp-application-crypto v2.0.1
Compiling sc-tracing v2.0.1
Compiling sp-runtime v2.0.1
Compiling sc-keystore v2.0.1
error: failed to run custom build command for `node-template-runtime v2.0.1 (C:\Users\matth\substrate-node-template\runtime)`
Caused by:
process didn't exit successfully: `C:\Users\matth\substrate-node-template\target\release\build\node-template-runtime-76c37493ab0ba7f5\build-script-build` (exit code: 1)
--- stdout
Information that should be included in a bug report.
Executing build command: "rustup" "run" "nightly-2020-10-05" "cargo" "-Zfeatures=build_dep" "rustc" "--target=wasm32-unknown-unknown" "--manifest-path=C:\\Users\\matth\\substrate-node-template\\target\\release\\wbuild\\node-template-runtime\\Cargo.toml" "--color=always" "--release"
Using rustc version: rustc 1.49.0-nightly (beb5ae474 2020-10-04)
--- stderr
warning: TOML file found which contains invalid syntax and will soon not parse
at `C:\Users\matth\substrate-node-template\pallets\template\Cargo.toml`.
The TOML spec requires that each table header is defined at most once, but
historical versions of Cargo have erroneously accepted this file. The table
definitions will need to be merged together with one table header to proceed,
and this will become a hard error in the future.
warning: TOML file found which contains invalid syntax and will soon not parse
at `C:\Users\matth\substrate-node-template\pallets\template\Cargo.toml`.
The TOML spec requires that each table header is defined at most once, but
historical versions of Cargo have erroneously accepted this file. The table
definitions will need to be merged together with one table header to proceed,
and this will become a hard error in the future.
Compiling substrate-wasm-builder v3.0.0
Compiling node-template-runtime v2.0.1 (C:\Users\matth\substrate-node-template\runtime)
Compiling pallet-template v2.0.1 (C:\Users\matth\substrate-node-template\pallets\template)
Compiling pallet-grandpa v2.0.1
error: Error { inner: ErrorInner { kind: DuplicateTable("dependencies"), line: Some(29), col: 0, at: Some(951), message: "", key: ["dependencies"] } }
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:18:1
|
18 | / decl_event! {
19 | | pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId {
20 | | /// Event emitted when a proof has been claimed. [who, claim]
21 | | ClaimCreated(AccountId, Vec<u8>),
... |
24 | | }
25 | | }
| |_^
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: Error { inner: ErrorInner { kind: DuplicateTable("dependencies"), line: Some(29), col: 0, at: Some(951), message: "", key: ["dependencies"] } }
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:18:1
|
18 | / decl_event! {
19 | | pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId {
20 | | /// Event emitted when a proof has been claimed. [who, claim]
21 | | ClaimCreated(AccountId, Vec<u8>),
... |
24 | | }
25 | | }
| |_^
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: Error { inner: ErrorInner { kind: DuplicateTable("dependencies"), line: Some(29), col: 0, at: Some(951), message: "", key: ["dependencies"] } }
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:42:1
|
42 | / decl_storage! {
43 | | trait Store for Module<T: Trait> as TemplateModule {
44 | | /// The storage item for our proofs.
45 | | /// It maps a proof to the user who made the claim and when they made it.
46 | | Proofs: map hasher(blake2_128_concat) Vec<u8> => (T::AccountId, T::BlockNumber);
47 | | }
48 | | }
| |_^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: Error { inner: ErrorInner { kind: DuplicateTable("dependencies"), line: Some(29), col: 0, at: Some(951), message: "", key: ["dependencies"] } }
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:53:1
|
53 | / decl_module! {
54 | | pub struct Module<T: Trait> for enum Call where origin: T::Origin {
55 | | // Errors must be initialized if they are used by the pallet.
56 | | type Error = Error<T>;
... |
105 | | }
106 | | }
| |_^
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: Error { inner: ErrorInner { kind: DuplicateTable("dependencies"), line: Some(29), col: 0, at: Some(951), message: "", key: ["dependencies"] } }
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:53:1
|
53 | / decl_module! {
54 | | pub struct Module<T: Trait> for enum Call where origin: T::Origin {
55 | | // Errors must be initialized if they are used by the pallet.
56 | | type Error = Error<T>;
... |
105 | | }
106 | | }
| |_^
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: maybe a missing crate `sp_api_hidden_includes_decl_storage`?
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:42:1
|
42 | / decl_storage! {
43 | | trait Store for Module<T: Trait> as TemplateModule {
44 | | /// The storage item for our proofs.
45 | | /// It maps a proof to the user who made the claim and when they made it.
46 | | Proofs: map hasher(blake2_128_concat) Vec<u8> => (T::AccountId, T::BlockNumber);
47 | | }
48 | | }
| |_^ maybe a missing crate `sp_api_hidden_includes_decl_storage`?
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: use of undeclared crate or module `_parity_scale_codec`
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:18:1
|
18 | / decl_event! {
19 | | pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId {
20 | | /// Event emitted when a proof has been claimed. [who, claim]
21 | | ClaimCreated(AccountId, Vec<u8>),
... |
24 | | }
25 | | }
| |_^ use of undeclared crate or module `_parity_scale_codec`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: use of undeclared crate or module `_parity_scale_codec`
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:18:1
|
18 | / decl_event! {
19 | | pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId {
20 | | /// Event emitted when a proof has been claimed. [who, claim]
21 | | ClaimCreated(AccountId, Vec<u8>),
... |
24 | | }
25 | | }
| |_^ use of undeclared crate or module `_parity_scale_codec`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: use of undeclared type `Encode`
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:42:1
|
42 | / decl_storage! {
43 | | trait Store for Module<T: Trait> as TemplateModule {
44 | | /// The storage item for our proofs.
45 | | /// It maps a proof to the user who made the claim and when they made it.
46 | | Proofs: map hasher(blake2_128_concat) Vec<u8> => (T::AccountId, T::BlockNumber);
47 | | }
48 | | }
| |_^ use of undeclared type `Encode`
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: use of undeclared crate or module `_parity_scale_codec`
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:53:1
|
53 | / decl_module! {
54 | | pub struct Module<T: Trait> for enum Call where origin: T::Origin {
55 | | // Errors must be initialized if they are used by the pallet.
56 | | type Error = Error<T>;
... |
105 | | }
106 | | }
| |_^ use of undeclared crate or module `_parity_scale_codec`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: use of undeclared crate or module `_parity_scale_codec`
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:53:1
|
53 | / decl_module! {
54 | | pub struct Module<T: Trait> for enum Call where origin: T::Origin {
55 | | // Errors must be initialized if they are used by the pallet.
56 | | type Error = Error<T>;
... |
105 | | }
106 | | }
| |_^ use of undeclared crate or module `_parity_scale_codec`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: use of undeclared crate or module `_parity_scale_codec`
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:21:22
|
21 | ClaimCreated(AccountId, Vec<u8>),
| ^^^^^^^^^ not found in `_parity_scale_codec`
|
help: consider importing one of these items
|
3 | use codec::Decode;
|
3 | use frame_support::dispatch::Decode;
|
error[E0433]: failed to resolve: use of undeclared crate or module `_parity_scale_codec`
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:21:33
|
21 | ClaimCreated(AccountId, Vec<u8>),
| ^^^^^^^ not found in `_parity_scale_codec`
|
help: consider importing one of these items
|
3 | use codec::Decode;
|
3 | use frame_support::dispatch::Decode;
|
error[E0433]: failed to resolve: use of undeclared crate or module `_parity_scale_codec`
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:23:22
|
23 | ClaimRevoked(AccountId, Vec<u8>),
| ^^^^^^^^^ not found in `_parity_scale_codec`
|
help: consider importing one of these items
|
3 | use codec::Decode;
|
3 | use frame_support::dispatch::Decode;
|
error[E0433]: failed to resolve: use of undeclared crate or module `_parity_scale_codec`
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:23:33
|
23 | ClaimRevoked(AccountId, Vec<u8>),
| ^^^^^^^ not found in `_parity_scale_codec`
|
help: consider importing one of these items
|
3 | use codec::Decode;
|
3 | use frame_support::dispatch::Decode;
|
error[E0433]: failed to resolve: maybe a missing crate `sp_api_hidden_includes_decl_storage`?
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:42:1
|
42 | / decl_storage! {
43 | | trait Store for Module<T: Trait> as TemplateModule {
44 | | /// The storage item for our proofs.
45 | | /// It maps a proof to the user who made the claim and when they made it.
46 | | Proofs: map hasher(blake2_128_concat) Vec<u8> => (T::AccountId, T::BlockNumber);
47 | | }
48 | | }
| |_^ not found in `self::sp_api_hidden_includes_decl_storage::hidden_include::metadata`
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this enum
|
3 | use frame_support::error::DecodeDifferent;
|
error[E0433]: failed to resolve: use of undeclared crate or module `_parity_scale_codec`
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:53:1
|
53 | / decl_module! {
54 | | pub struct Module<T: Trait> for enum Call where origin: T::Origin {
55 | | // Errors must be initialized if they are used by the pallet.
56 | | type Error = Error<T>;
... |
105 | | }
106 | | }
| |_^ not found in `_parity_scale_codec`
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing one of these items
|
3 | use codec::Decode;
|
3 | use frame_support::dispatch::Decode;
|
error[E0433]: failed to resolve: use of undeclared crate or module `_parity_scale_codec`
--> C:\Users\matth\substrate-node-template\pallets\template\src\lib.rs:53:1
|
53 | / decl_module! {
54 | | pub struct Module<T: Trait> for enum Call where origin: T::Origin {
55 | | // Errors must be initialized if they are used by the pallet.
56 | | type Error = Error<T>;
... |
105 | | }
106 | | }
| |_^ not found in `_parity_scale_codec`
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing one of these items
|
3 | use codec::Decode;
|
3 | use frame_support::dispatch::Decode;
|
error: aborting due to 18 previous errors
For more information about this error, try `rustc --explain E0433`.
error: could not compile `pallet-template`
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
warning: build failed, waiting for other jobs to finish...
error: build failed
$ rustup show
Default host: x86_64-pc-windows-msvc
rustup home: C:\Users\matth\.rustup
installed toolchains
--------------------
stable-x86_64-pc-windows-msvc
nightly-2020-10-05-x86_64-pc-windows-msvc (default)
nightly-x86_64-pc-windows-msvc
installed targets for active toolchain
--------------------------------------
wasm32-unknown-unknown
x86_64-pc-windows-msvc
active toolchain
----------------
nightly-2020-10-05-x86_64-pc-windows-msvc (default)
rustc 1.49.0-nightly (beb5ae474 2020-10-04)
Answer provided by NukeManDan should work fine. Also, cargo update -p <package_name> should do the trick, I guess.

proc_open() fork fails in Laravel controller

I get an error saying: proc_open(): fork failed - Cannot allocate memory in a Laravel controller. The generate function is called with axios (Vuejs SAP).
This is what my controller looks like
use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use GifCreator\AnimGif;
use simpleimage\SimpleImage;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
class GifController extends Controller
{
//
public function generate(Request $request)
{
if(!$request->ajax()) return;
$cmd = 'ls';
$process = new Process($cmd);
$process->run();
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
echo $process->getOutput();
}
}
free -m on server:
| | total | used | free | shared | buff/cache | available |
| ----- | ------ | ----- | ---- | ------ | ---------- | --------- |
| Mem: | 2000 | 243 | 577 | 20 | 1178 | 1541 |
| Swap: | 4095 | 0 | 4095 | | | |
EDIT:
As Hilmi pointed out I've now tried adding a swap space, and now the command runs successfully sometimes – about half of the time.
Is there a way to retry the Process if it fails?

How do I make Fastlane Deliver work for tvOS?

Upload to iTunesConnect fails with the following error:
"Invalid Provisioning Profile. This provisioning profile is not compatible with iOS apps."
+-----------------------+---------------------------------------+
| deliver 2.26.1 Summary |
+-----------------------+---------------------------------------+
| username | iosdev#inspirato.com |
| ipa | /Users/vagrant/deploy/InspiratoTV.ipa |
| skip_screenshots | true |
| skip_metadata | true |
| force | true |
| app_identifier | com.inspirato.travel.InspiratoTV |
| screenshots_path | ./screenshots |
| metadata_path | ./metadata |
| app_version | 1.0 |
| edit_live | false |
| platform | ios |
| skip_binary_upload | false |
| submit_for_review | false |
| automatic_release | false |
| overwrite_screenshots | false |
+-----------------------+---------------------------------------+
It appears that the platform is stuck on "ios" even though I don't have an iOS related app for this bundle ID. I've tried adding "--platform tvOS" to the end of the $ fastlane deliver ... command with no luck.
Deliver uses the notation "appletvos" for the tvOS platform.
Add that to the end of the $ fastlane deliver command:
$ fastlane deliver ... ... "--platform" "appletvos"
Or add it to your .Deliver file like so:
deliver(platform: "appletvos")
If you use upload_to_testflight, please, specify appletvos as an app platform
upload_to_testflight(app_platform: "appletvos")
And don't forget to set build(include_bitcode: true) during the build.
If you use match for signing specify a platform parameter:
match(platform: "tvos")
If you use a repository for match add a _tvos suffix to your provisioning profile name. For example, file
profiles/appstore/AppStore_com.yourcompany.youproject.mobileprovision
must be renamed to
profiles/appstore/AppStore_com.yourcompany.youproject_tvos.mobileprovision
This is necessary to avoid an error with match/sigh.

How many leafref is possible inside a leaf in Yang modelling?

According to RFC - RFC 6020 - LeafRef I can understand that the leaf can contain a leafref which inturn have the path pointing to the instance which is referenced but question is how many leafrefs are possible for one leaf? Only one or many?
Ex.
leaf mgmt-interface {
type leafref {
path "../interface/name";
}
type leafref {
path "../interface/ip";
}
}
Is the above possible?
A leafref may only target a single leaf or leaf-list node via path. There may only be one type substatement to a leaf (also applies to leaf-list, typedef) and there may only be a single path substatement to type.
7.6.2. The leaf's Substatements
+--------------+---------+-------------+
| substatement | section | cardinality |
+--------------+---------+-------------+
| config | 7.19.1 | 0..1 |
| default | 7.6.4 | 0..1 |
| description | 7.19.3 | 0..1 |
| if-feature | 7.18.2 | 0..n |
| mandatory | 7.6.5 | 0..1 |
| must | 7.5.3 | 0..n |
| reference | 7.19.4 | 0..1 |
| status | 7.19.2 | 0..1 |
| type | 7.6.3 | 1 | <--
| units | 7.3.3 | 0..1 |
| when | 7.19.5 | 0..1 |
+--------------+---------+-------------+
12. YANG ABNF Grammar
type-stmt = type-keyword sep identifier-ref-arg-str optsep
(";" /
"{" stmtsep
type-body-stmts
"}")
type-body-stmts = numerical-restrictions /
decimal64-specification /
string-restrictions /
enum-specification /
leafref-specification /
identityref-specification /
instance-identifier-specification /
bits-specification /
union-specification
leafref-specification =
;; these stmts can appear in any order
path-stmt stmtsep
[require-instance-stmt stmtsep]
path-stmt = path-keyword sep path-arg-str stmtend
Note: it is not possible to use union for leafref types in YANG 1.0. This has changed in YANG 1.1 however, where any built-in YANG type may appear inside a union.
9.12. The union Built-In Type
A member type can be of any built-in or derived type, except it MUST
NOT be one of the built-in types "empty" or "leafref".

Resources