Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Offchain-worker: Update example-offchain-worker with implementation for TestAuthId #10096

Merged
merged 4 commits into from
Oct 25, 2021

Conversation

ltfschoen
Copy link
Contributor

@ltfschoen ltfschoen commented Oct 25, 2021

i tried to incorporate the off-chain worker callback demo as a custom pallet of my own Substrate-based blockchain implementation that's provided at the following links

error[E0277]: the trait bound `AuthorityId: AppCrypto<MultiSigner, MultiSignature>` is not satisfied
--> /Users/me/my_repo/node/runtime/src/lib.rs:1172:5
|
1172 |     type AuthorityId = AuthorityId;
|     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AppCrypto<MultiSigner, MultiSignature>` is not implemented for `AuthorityId`
|
note: required by a bound in `offchaincb::Config::AuthorityId`
--> /Users/me/my_repo/node/pallets/offchaincb/src/lib.rs:169:21
|
169  |         type AuthorityId: AppCrypto<Self::Public, Self::Signature>;
|                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `offchaincb::Config::AuthorityId`

where in my custom pallet i have:

pallets/offchaincb/src/lib.rs

...

use offchaincb::{
    crypto::{
        TestAuthId,
    },
};

...

parameter_types! {
	pub const GracePeriod: BlockNumber = 1 * MINUTES;
	pub const UnsignedInterval: BlockNumber = 1 * MINUTES;
        pub const UnsignedPriority: BlockNumber = 1 * MINUTES;
}

impl offchaincb::Config for Runtime {
    type AuthorityId = TestAuthId;
    type Call = Call;
    type Currency = Balances;
    type Event = Event;
    type GracePeriod = GracePeriod;
    type UnsignedInterval = UnsignedInterval;
    type UnsignedPriority = UnsignedPriority;
}

...

then i found another different off-chain workers Substrate Recipe demo from Jimmy Chu @jimmychu0807 https://github.com/jimmychu0807/recipes/blob/master/pallets/ocw-demo/src/lib.rs#L73 which had an extra implementation for TestAuthId here https://github.com/jimmychu0807/recipes/blob/master/pallets/ocw-demo/src/lib.rs#L73, and when i added that it overcame the error.

so i think this change should be included in the Substrate repository

…TestAuthId

i tried to incorporate the off-chain worker callback demo as a custom pallet of my own Substrate-based blockchain implementation that's provided at the following links
* https://www.parity.io/blog/substrate-off-chain-workers-secure-and-efficient-computing-intensive-tasks/
* https://gnunicorn.github.io/substrate-offchain-cb/
but when i build the code with `cargo build --release`, it gave me an error:
```
error[E0277]: the trait bound `AuthorityId: AppCrypto<MultiSigner, MultiSignature>` is not satisfied
--> /Users/me/my_repo/node/runtime/src/lib.rs:1172:5
|
1172 |     type AuthorityId = AuthorityId;
|     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AppCrypto<MultiSigner, MultiSignature>` is not implemented for `AuthorityId`
|
note: required by a bound in `offchaincb::Config::AuthorityId`
--> /Users/me/my_repo/node/pallets/offchaincb/src/lib.rs:169:21
|
169  |         type AuthorityId: AppCrypto<Self::Public, Self::Signature>;
|                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `offchaincb::Config::AuthorityId`
```

where in my custom pallet i have:

pallets/offchaincb/src/lib.rs

```
...

use offchaincb::{
    crypto::{
        TestAuthId,
    },
};

...

parameter_types! {
	pub const GracePeriod: BlockNumber = 1 * MINUTES;
	pub const UnsignedInterval: BlockNumber = 1 * MINUTES;
        pub const UnsignedPriority: BlockNumber = 1 * MINUTES;
}

impl offchaincb::Config for Runtime {
    type AuthorityId = TestAuthId;
    type Call = Call;
    type Currency = Balances;
    type Event = Event;
    type GracePeriod = GracePeriod;
    type UnsignedInterval = UnsignedInterval;
    type UnsignedPriority = UnsignedPriority;
}

...
```

then i found another different off-chain workers Substrate Recipe demo from Jimmy Chu https://github.com/jimmychu0807/recipes/blob/master/pallets/ocw-demo/src/lib.rs#L73 which had an extra implementation for TestAuthId here https://github.com/jimmychu0807/recipes/blob/master/pallets/ocw-demo/src/lib.rs#L73, and when i added that it overcame the error.

so i think this change should be included in the Substrate repository
@ltfschoen ltfschoen changed the title Update example-offchain-worker with implementation for TestAuthId Offchain worker: Update example-offchain-worker with implementation for TestAuthId Oct 25, 2021
@ltfschoen ltfschoen changed the title Offchain worker: Update example-offchain-worker with implementation for TestAuthId Offchain-worker: Update example-offchain-worker with implementation for TestAuthId Oct 25, 2021
@bkchr
Copy link
Member

bkchr commented Oct 25, 2021

You need to run cargo fmt

@bkchr bkchr added A2-insubstantial Pull request requires no code review (e.g., a sub-repository hash update). B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Oct 25, 2021
@bkchr
Copy link
Member

bkchr commented Oct 25, 2021

bot merge

@paritytech-processbot
Copy link

Waiting for commit status.

@paritytech-processbot
Copy link

Bot will approve on the behalf of @bkchr, since they are a team lead, in an attempt to reach the minimum approval count

@paritytech-processbot paritytech-processbot bot merged commit 732f037 into paritytech:master Oct 25, 2021
grishasobol pushed a commit to gear-tech/substrate that referenced this pull request Mar 28, 2022
…or TestAuthId (paritytech#10096)

* Update example-offchain-worker to include missing implementation for TestAuthId

i tried to incorporate the off-chain worker callback demo as a custom pallet of my own Substrate-based blockchain implementation that's provided at the following links
* https://www.parity.io/blog/substrate-off-chain-workers-secure-and-efficient-computing-intensive-tasks/
* https://gnunicorn.github.io/substrate-offchain-cb/
but when i build the code with `cargo build --release`, it gave me an error:
```
error[E0277]: the trait bound `AuthorityId: AppCrypto<MultiSigner, MultiSignature>` is not satisfied
--> /Users/me/my_repo/node/runtime/src/lib.rs:1172:5
|
1172 |     type AuthorityId = AuthorityId;
|     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AppCrypto<MultiSigner, MultiSignature>` is not implemented for `AuthorityId`
|
note: required by a bound in `offchaincb::Config::AuthorityId`
--> /Users/me/my_repo/node/pallets/offchaincb/src/lib.rs:169:21
|
169  |         type AuthorityId: AppCrypto<Self::Public, Self::Signature>;
|                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `offchaincb::Config::AuthorityId`
```

where in my custom pallet i have:

pallets/offchaincb/src/lib.rs

```
...

use offchaincb::{
    crypto::{
        TestAuthId,
    },
};

...

parameter_types! {
	pub const GracePeriod: BlockNumber = 1 * MINUTES;
	pub const UnsignedInterval: BlockNumber = 1 * MINUTES;
        pub const UnsignedPriority: BlockNumber = 1 * MINUTES;
}

impl offchaincb::Config for Runtime {
    type AuthorityId = TestAuthId;
    type Call = Call;
    type Currency = Balances;
    type Event = Event;
    type GracePeriod = GracePeriod;
    type UnsignedInterval = UnsignedInterval;
    type UnsignedPriority = UnsignedPriority;
}

...
```

then i found another different off-chain workers Substrate Recipe demo from Jimmy Chu https://github.com/jimmychu0807/recipes/blob/master/pallets/ocw-demo/src/lib.rs#L73 which had an extra implementation for TestAuthId here https://github.com/jimmychu0807/recipes/blob/master/pallets/ocw-demo/src/lib.rs#L73, and when i added that it overcame the error.

so i think this change should be included in the Substrate repository

* Fix indentation

* Fix formatting

* Swap order
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
…or TestAuthId (paritytech#10096)

* Update example-offchain-worker to include missing implementation for TestAuthId

i tried to incorporate the off-chain worker callback demo as a custom pallet of my own Substrate-based blockchain implementation that's provided at the following links
* https://www.parity.io/blog/substrate-off-chain-workers-secure-and-efficient-computing-intensive-tasks/
* https://gnunicorn.github.io/substrate-offchain-cb/
but when i build the code with `cargo build --release`, it gave me an error:
```
error[E0277]: the trait bound `AuthorityId: AppCrypto<MultiSigner, MultiSignature>` is not satisfied
--> /Users/me/my_repo/node/runtime/src/lib.rs:1172:5
|
1172 |     type AuthorityId = AuthorityId;
|     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AppCrypto<MultiSigner, MultiSignature>` is not implemented for `AuthorityId`
|
note: required by a bound in `offchaincb::Config::AuthorityId`
--> /Users/me/my_repo/node/pallets/offchaincb/src/lib.rs:169:21
|
169  |         type AuthorityId: AppCrypto<Self::Public, Self::Signature>;
|                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `offchaincb::Config::AuthorityId`
```

where in my custom pallet i have:

pallets/offchaincb/src/lib.rs

```
...

use offchaincb::{
    crypto::{
        TestAuthId,
    },
};

...

parameter_types! {
	pub const GracePeriod: BlockNumber = 1 * MINUTES;
	pub const UnsignedInterval: BlockNumber = 1 * MINUTES;
        pub const UnsignedPriority: BlockNumber = 1 * MINUTES;
}

impl offchaincb::Config for Runtime {
    type AuthorityId = TestAuthId;
    type Call = Call;
    type Currency = Balances;
    type Event = Event;
    type GracePeriod = GracePeriod;
    type UnsignedInterval = UnsignedInterval;
    type UnsignedPriority = UnsignedPriority;
}

...
```

then i found another different off-chain workers Substrate Recipe demo from Jimmy Chu https://github.com/jimmychu0807/recipes/blob/master/pallets/ocw-demo/src/lib.rs#L73 which had an extra implementation for TestAuthId here https://github.com/jimmychu0807/recipes/blob/master/pallets/ocw-demo/src/lib.rs#L73, and when i added that it overcame the error.

so i think this change should be included in the Substrate repository

* Fix indentation

* Fix formatting

* Swap order
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A2-insubstantial Pull request requires no code review (e.g., a sub-repository hash update). B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants