1
1
use std:: collections:: HashMap ;
2
- use std:: ops:: RangeInclusive ;
3
2
use std:: sync:: { Arc , Mutex } ;
4
3
5
4
use anyhow:: anyhow;
@@ -18,7 +17,7 @@ use super::externs::CgoExterns;
18
17
use super :: types:: * ;
19
18
20
19
// Generic executor; uses the current (v3) engine types
21
- pub trait CgoExecutor {
20
+ pub trait CgoExecutor : Send {
22
21
fn execute_message (
23
22
& mut self ,
24
23
msg : Message ,
@@ -65,9 +64,6 @@ pub struct MultiEngineContainer {
65
64
engines : Mutex < HashMap < EngineVersion , Arc < dyn AbstractMultiEngine + ' static > > > ,
66
65
}
67
66
68
- const LOTUS_FVM_CONCURRENCY_ENV_NAME : & str = "LOTUS_FVM_CONCURRENCY" ;
69
- const VALID_CONCURRENCY_RANGE : RangeInclusive < u32 > = 1 ..=128 ;
70
-
71
67
impl TryFrom < u32 > for EngineVersion {
72
68
type Error = anyhow:: Error ;
73
69
fn try_from ( value : u32 ) -> Result < Self , Self :: Error > {
@@ -81,41 +77,6 @@ impl TryFrom<u32> for EngineVersion {
81
77
}
82
78
83
79
impl MultiEngineContainer {
84
- /// Constructs a new multi-engine container with the default concurrency (4).
85
- pub fn new ( ) -> MultiEngineContainer {
86
- Self :: with_concurrency ( 4 )
87
- }
88
-
89
- /// Constructs a new multi-engine container with the concurrency specified in the
90
- /// `LOTUS_FVM_CONCURRENCY` environment variable.
91
- pub fn new_env ( ) -> MultiEngineContainer {
92
- let valosstr = match std:: env:: var_os ( LOTUS_FVM_CONCURRENCY_ENV_NAME ) {
93
- Some ( v) => v,
94
- None => return Self :: new ( ) ,
95
- } ;
96
- let valstr = match valosstr. to_str ( ) {
97
- Some ( s) => s,
98
- None => {
99
- log:: error!( "{LOTUS_FVM_CONCURRENCY_ENV_NAME} has invalid value" ) ;
100
- return Self :: new ( ) ;
101
- }
102
- } ;
103
- let concurrency: u32 = match valstr. parse ( ) {
104
- Ok ( v) => v,
105
- Err ( e) => {
106
- log:: error!( "{LOTUS_FVM_CONCURRENCY_ENV_NAME} has invalid value: {e}" ) ;
107
- return Self :: new ( ) ;
108
- }
109
- } ;
110
- if !VALID_CONCURRENCY_RANGE . contains ( & concurrency) {
111
- log:: error!(
112
- "{LOTUS_FVM_CONCURRENCY_ENV_NAME} must be in the range {VALID_CONCURRENCY_RANGE:?}, not {concurrency}"
113
- ) ;
114
- return Self :: new ( ) ;
115
- }
116
- Self :: with_concurrency ( concurrency)
117
- }
118
-
119
80
pub fn with_concurrency ( concurrency : u32 ) -> MultiEngineContainer {
120
81
MultiEngineContainer {
121
82
engines : Mutex :: new ( HashMap :: new ( ) ) ,
@@ -146,12 +107,6 @@ impl MultiEngineContainer {
146
107
}
147
108
}
148
109
149
- impl Default for MultiEngineContainer {
150
- fn default ( ) -> MultiEngineContainer {
151
- MultiEngineContainer :: new ( )
152
- }
153
- }
154
-
155
110
// fvm v4 implementation
156
111
mod v4 {
157
112
use anyhow:: anyhow;
@@ -160,10 +115,7 @@ mod v4 {
160
115
161
116
use fvm4:: call_manager:: DefaultCallManager as DefaultCallManager4 ;
162
117
use fvm4:: engine:: { EnginePool as EnginePool4 , MultiEngine as MultiEngine4 } ;
163
- use fvm4:: executor:: {
164
- ApplyKind , ApplyRet , DefaultExecutor as DefaultExecutor4 ,
165
- ThreadedExecutor as ThreadedExecutor4 ,
166
- } ;
118
+ use fvm4:: executor:: { ApplyKind , ApplyRet , DefaultExecutor as DefaultExecutor4 } ;
167
119
use fvm4:: kernel:: filecoin:: DefaultFilecoinKernel as DefaultFilecoinKernel4 ;
168
120
use fvm4:: machine:: { DefaultMachine as DefaultMachine4 , NetworkConfig } ;
169
121
use fvm4_shared:: { chainid:: ChainID , clock:: ChainEpoch , message:: Message } ;
@@ -175,14 +127,13 @@ mod v4 {
175
127
use super :: Config ;
176
128
177
129
type CgoMachine4 = DefaultMachine4 < CgoBlockstore , CgoExterns > ;
178
- type BaseExecutor4 = DefaultExecutor4 < DefaultFilecoinKernel4 < DefaultCallManager4 < CgoMachine4 > > > ;
179
- type CgoExecutor4 = ThreadedExecutor4 < BaseExecutor4 > ;
130
+ type CgoExecutor4 = DefaultExecutor4 < DefaultFilecoinKernel4 < DefaultCallManager4 < CgoMachine4 > > > ;
180
131
181
132
fn new_executor (
182
133
engine_pool : EnginePool4 ,
183
134
machine : CgoMachine4 ,
184
135
) -> anyhow:: Result < CgoExecutor4 > {
185
- Ok ( ThreadedExecutor4 ( BaseExecutor4 :: new ( engine_pool, machine) ? ) )
136
+ CgoExecutor4 :: new ( engine_pool, machine)
186
137
}
187
138
188
139
impl CgoExecutor for CgoExecutor4 {
@@ -254,8 +205,7 @@ mod v3 {
254
205
} ;
255
206
use fvm3:: engine:: { EnginePool as EnginePool3 , MultiEngine as MultiEngine3 } ;
256
207
use fvm3:: executor:: {
257
- ApplyFailure as ApplyFailure3 , ApplyKind as ApplyKind3 ,
258
- DefaultExecutor as DefaultExecutor3 , ThreadedExecutor as ThreadedExecutor3 ,
208
+ ApplyFailure as ApplyFailure3 , ApplyKind as ApplyKind3 , DefaultExecutor as DefaultExecutor3 ,
259
209
} ;
260
210
use fvm3:: machine:: { DefaultMachine as DefaultMachine3 , NetworkConfig as NetworkConfig3 } ;
261
211
use fvm3:: trace:: ExecutionEvent as ExecutionEvent3 ;
@@ -284,14 +234,13 @@ mod v3 {
284
234
use super :: Config ;
285
235
286
236
type CgoMachine3 = DefaultMachine3 < CgoBlockstore , CgoExterns > ;
287
- type BaseExecutor3 = DefaultExecutor3 < DefaultKernel3 < DefaultCallManager3 < CgoMachine3 > > > ;
288
- type CgoExecutor3 = ThreadedExecutor3 < BaseExecutor3 > ;
237
+ type CgoExecutor3 = DefaultExecutor3 < DefaultKernel3 < DefaultCallManager3 < CgoMachine3 > > > ;
289
238
290
239
fn new_executor (
291
240
engine_pool : EnginePool3 ,
292
241
machine : CgoMachine3 ,
293
242
) -> anyhow:: Result < CgoExecutor3 > {
294
- Ok ( ThreadedExecutor3 ( BaseExecutor3 :: new ( engine_pool, machine) ? ) )
243
+ CgoExecutor3 :: new ( engine_pool, machine)
295
244
}
296
245
297
246
impl CgoExecutor for CgoExecutor3 {
@@ -533,8 +482,7 @@ mod v2 {
533
482
backtrace:: Cause as Cause2 , DefaultCallManager as DefaultCallManager2 ,
534
483
} ;
535
484
use fvm2:: executor:: {
536
- ApplyFailure as ApplyFailure2 , ApplyKind as ApplyKind2 ,
537
- DefaultExecutor as DefaultExecutor2 , ThreadedExecutor as ThreadedExecutor2 ,
485
+ ApplyFailure as ApplyFailure2 , ApplyKind as ApplyKind2 , DefaultExecutor as DefaultExecutor2 ,
538
486
} ;
539
487
use fvm2:: machine:: {
540
488
DefaultMachine as DefaultMachine2 , MultiEngine as MultiEngine2 ,
@@ -565,11 +513,10 @@ mod v2 {
565
513
use super :: Config ;
566
514
567
515
type CgoMachine2 = DefaultMachine2 < CgoBlockstore , CgoExterns > ;
568
- type BaseExecutor2 = DefaultExecutor2 < DefaultKernel2 < DefaultCallManager2 < CgoMachine2 > > > ;
569
- type CgoExecutor2 = ThreadedExecutor2 < BaseExecutor2 > ;
516
+ type CgoExecutor2 = DefaultExecutor2 < DefaultKernel2 < DefaultCallManager2 < CgoMachine2 > > > ;
570
517
571
518
fn new_executor ( machine : CgoMachine2 ) -> CgoExecutor2 {
572
- ThreadedExecutor2 ( BaseExecutor2 :: new ( machine) )
519
+ CgoExecutor2 :: new ( machine)
573
520
}
574
521
575
522
fn bytes_to_block ( bytes : RawBytes ) -> Option < IpldBlock > {
0 commit comments