Skip to content

Commit 911d319

Browse files
authored
Merge pull request ipfs-force-community#1084 from ipfs-force-community/feat/0x5459/support-sealing-daemons
feat(worker): support custom sealing daemon processor
2 parents 04197ca + a30b807 commit 911d319

File tree

8 files changed

+41
-1
lines changed

8 files changed

+41
-1
lines changed

CHANGELOG.zh.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.11.0
4+
- damocles-worker
5+
- 支持以子进程方式启动自定义守护进程. 新增配置项目: `[[processors.sealing_daemons]]`[#1084](https://github.com/ipfs-force-community/damocles/pull/1084)
6+
37
## 0.10.0-rc1
48

59
- 支持 NV22 DDO [#1071](https://github.com/ipfs-force-community/damocles/pull/1071)

damocles-worker/src/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ pub struct Processors {
229229

230230
/// section for window_post processor
231231
pub window_post: Option<Vec<Ext>>,
232+
233+
/// section for sealing_daemons processor
234+
pub sealing_daemons: Option<Vec<Ext>>,
232235
}
233236

234237
impl Processors {

damocles-worker/src/run.rs

+1
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ fn start_processors(
328328
transfer: construct_sub_processor!(transfer, cfg, limit),
329329
unseal: construct_sub_processor!(unseal, cfg, limit),
330330
window_post: construct_sub_processor!(window_post, cfg, limit),
331+
sealing_daemons: construct_sub_processor!(sealing_daemons, cfg, limit),
331332
})
332333
}
333334

damocles-worker/src/watchdog.rs

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ pub(crate) struct GlobalProcessors {
6767
pub transfer: Proc<TransferInput>,
6868
pub unseal: Proc<UnsealInput>,
6969
pub window_post: Proc<WindowPoStInput>,
70+
#[allow(dead_code)]
71+
pub sealing_daemons: Proc<()>,
7072
}
7173

7274
impl Module for Box<dyn Module> {

damocles-worker/vc-processors/src/builtin/processors.rs

+10
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ mod transfer;
2727
#[derive(Copy, Clone, Default, Debug)]
2828
pub struct BuiltinProcessor;
2929

30+
impl Processor<()> for BuiltinProcessor {
31+
fn name(&self) -> String {
32+
String::new()
33+
}
34+
35+
fn process(&self, _: ()) -> Result<<() as Task>::Output> {
36+
Ok(())
37+
}
38+
}
39+
3040
impl Processor<AddPieces> for BuiltinProcessor {
3141
fn name(&self) -> String {
3242
"builtin AddPieces".to_string()

damocles-worker/vc-processors/src/core/mod.rs

+19
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,22 @@ impl<T: Task> Processor<T> for Box<dyn Processor<T>> {
5151
(**self).process(task)
5252
}
5353
}
54+
55+
impl Task for () {
56+
const STAGE: &'static str = "EMPTY";
57+
type Output = ();
58+
}
59+
60+
/// The DaemonProcessor does nothing
61+
#[derive(Debug, Default, Clone, Copy)]
62+
pub struct DaemonProcessor;
63+
64+
impl Processor<()> for DaemonProcessor {
65+
fn name(&self) -> String {
66+
String::new()
67+
}
68+
69+
fn process(&self, _: ()) -> Result<<() as Task>::Output> {
70+
Ok(())
71+
}
72+
}

docs/en/03.damocles-worker-config.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ Currently `{stage_name}` could be one of the following.
589589
- `c2`: for Commit2 phase
590590
- `unseal`: for unseal phase
591591
- `transfer`: used to customize the transfer method between local data and persistent data storage
592-
592+
- `sealing_daemons`: used to start some custom daemons
593593

594594
Each such configuration group translates to an external processor of the corresponding sealing phase to be started. If nothing is configured for one of the above `{stage_name}` and corresponding `[[processors.{stage_name}]]` line does not exist in the configuration file,
595595
then `damocles-worker` will not start a child process for this `{stage_name}`. `damocles-worker` will use the built-in processor code to directly execute the corresponding `{stage_name}` task in `sealing_thread`, which means that the concurrent number of `{stage_name}` tasks depends on the corresponding number of `sealing_thread` and concurrent number of `{stage_name}` as configured in `[processors.limitation.concurrent]`. By not configuring external processor saves extra steps such as serializing task parameters and task output, but one loses capabilities such as more powerful concurrency control, cgroup control, and custom proof algorithms. You are feel to choose according to your own needs.

docs/zh/03.damocles-worker的配置解析.md

+1
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ locks = ["gpu2"]
602602
- `c2`:用于 Commit2 阶段
603603
- `transfer`:用于自定义本地数据和持久化数据存储之间的传输方式
604604
- `unseal`: 用于 Unseal 阶段
605+
- `sealing_daemons` 用于启动一些自定义的守护进程
605606

606607

607608
每一个这样的配置组意味着将启动一个对应阶段的外部执行器。如果没有为上述的某个 `{stage_name}` 配置组配置任何内容,且配置中不存在对应的 `[[processors.{stage_name}]]` 这一行配置,

0 commit comments

Comments
 (0)