-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat/ocw/bookkeeping #5200
feat/ocw/bookkeeping #5200
Changes from all commits
6a779f3
75cbe3d
f82ff29
43fefee
08853b0
64a5dac
8769de9
701ea04
2aa7c5f
b1249a9
f61221a
1626cc1
798695d
eb5bc86
a7d990a
9b0012c
b27ff76
32ae2ed
62ccc60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,77 @@ | ||||
| // Copyright 2020 Parity Technologies (UK) Ltd. | ||||
| // This file is part of Substrate. | ||||
|
|
||||
| // Substrate is free software: you can redistribute it and/or modify | ||||
| // it under the terms of the GNU General Public License as published by | ||||
| // the Free Software Foundation, either version 3 of the License, or | ||||
| // (at your option) any later version. | ||||
|
|
||||
| // Substrate is distributed in the hope that it will be useful, | ||||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
| // GNU General Public License for more details. | ||||
|
|
||||
| // You should have received a copy of the GNU General Public License | ||||
| // along with Substrate. If not, see <http://www.gnu.org/licenses/>. | ||||
|
|
||||
rphmeier marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
|
|
||||
drahnr marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
| //! Offchain worker related configuration parameters. | ||||
| //! | ||||
| //! A subset of configuration parameters which are relevant to | ||||
| //! the inner working of offchain workers. The usage is solely | ||||
| //! targeted at handling input parameter parsing providing | ||||
| //! a reasonable abstraction. | ||||
|
|
||||
| use structopt::StructOpt; | ||||
| use sc_service::config::OffchainWorkerConfig; | ||||
| use sc_network::config::Role; | ||||
|
|
||||
| use crate::error; | ||||
| use crate::OffchainWorkerEnabled; | ||||
|
|
||||
|
|
||||
| /// Offchain worker related parameters. | ||||
| #[derive(Debug, StructOpt, Clone)] | ||||
| pub struct OffchainWorkerParams { | ||||
| /// Should execute offchain workers on every block. | ||||
| /// | ||||
| /// By default it's only enabled for nodes that are authoring new blocks. | ||||
| #[structopt( | ||||
| long = "offchain-worker", | ||||
| value_name = "ENABLED", | ||||
| possible_values = &OffchainWorkerEnabled::variants(), | ||||
| case_insensitive = true, | ||||
| default_value = "WhenValidating" | ||||
| )] | ||||
| pub enabled: OffchainWorkerEnabled, | ||||
|
|
||||
| /// Enable Offchain Indexing API, which allows block import to write to Offchain DB. | ||||
| /// | ||||
| /// Enables a runtime to write directly to a offchain workers | ||||
drahnr marked this conversation as resolved.
Show resolved
Hide resolved
drahnr marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
| /// DB during block import. | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
| #[structopt( | ||||
| long = "enable-offchain-indexing", | ||||
| value_name = "ENABLE_OFFCHAIN_INDEXING" | ||||
| )] | ||||
| pub indexing_enabled: bool, | ||||
drahnr marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wpank @shawntabrizi we're going to want validators to run with this flag. Are there documentation updates corresponding? @drahnr @tomusdrw Otherwise, would it make sense to automatically set
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see a particular reason why it should should be disabled for validators by default. |
||||
| } | ||||
|
|
||||
| impl OffchainWorkerParams { | ||||
| /// Load spec to `Configuration` from `OffchainWorkerParams` and spec factory. | ||||
| pub fn offchain_worker( | ||||
| &self, | ||||
| role: &Role, | ||||
| ) -> error::Result<OffchainWorkerConfig> | ||||
| { | ||||
| let enabled = match (&self.enabled, role) { | ||||
| (OffchainWorkerEnabled::WhenValidating, Role::Authority { .. }) => true, | ||||
| (OffchainWorkerEnabled::Always, _) => true, | ||||
| (OffchainWorkerEnabled::Never, _) => false, | ||||
| (OffchainWorkerEnabled::WhenValidating, _) => false, | ||||
| }; | ||||
|
|
||||
| let indexing_enabled = enabled && self.indexing_enabled; | ||||
|
|
||||
| Ok(OffchainWorkerConfig { enabled, indexing_enabled }) | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a fan of bundling the two settings together in one "worker" config. I think we should clearly separate this two things. But I can live with this, and would prefer to merge the PR earlier. |
||||
| } | ||||
| } | ||||
Uh oh!
There was an error while loading. Please reload this page.