1
1
// Copyright 2019-2022 ChainSafe Systems
2
2
// SPDX-License-Identifier: Apache-2.0, MIT
3
- use anyhow:: anyhow;
4
3
use cid:: { multihash, Cid } ;
5
4
use fvm_ipld_blockstore:: Blockstore ;
6
5
use fvm_ipld_encoding:: tuple:: * ;
@@ -12,13 +11,13 @@ use num_derive::FromPrimitive;
12
11
use num_traits:: FromPrimitive ;
13
12
14
13
use fil_actors_runtime:: runtime:: { ActorCode , Runtime } ;
15
- use fil_actors_runtime:: { actor_error, ActorDowncast , ActorError , SYSTEM_ACTOR_ADDR } ;
14
+ use fil_actors_runtime:: {
15
+ actor_error, ActorContext , ActorDowncast , ActorError , AsActorError , SYSTEM_ACTOR_ADDR ,
16
+ } ;
16
17
17
18
#[ cfg( feature = "fil-actor" ) ]
18
19
fil_actors_runtime:: wasm_trampoline!( Actor ) ;
19
20
20
- // * Updated to specs-actors commit: 845089a6d2580e46055c24415a6c32ee688e5186 (v3.0.0)
21
-
22
21
/// System actor methods.
23
22
#[ derive( FromPrimitive ) ]
24
23
#[ repr( u64 ) ]
@@ -35,10 +34,10 @@ pub struct State {
35
34
impl Cbor for State { }
36
35
37
36
impl State {
38
- pub fn new < BS : Blockstore > ( store : & BS ) -> anyhow :: Result < Self > {
37
+ pub fn new < BS : Blockstore > ( store : & BS ) -> Result < Self , ActorError > {
39
38
let c = store
40
39
. put_cbor ( & Vec :: < ( String , Cid ) > :: new ( ) , multihash:: Code :: Blake2b256 )
41
- . map_err ( |e| anyhow ! ( "failed to put system state to store: {}" , e ) ) ?;
40
+ . context_code ( ExitCode :: USR_ILLEGAL_STATE , "failed to store system state" ) ?;
42
41
Ok ( Self { builtin_actors : c } )
43
42
}
44
43
@@ -65,9 +64,7 @@ impl Actor {
65
64
{
66
65
rt. validate_immediate_caller_is ( std:: iter:: once ( & * SYSTEM_ACTOR_ADDR ) ) ?;
67
66
68
- let state = State :: new ( rt. store ( ) ) . map_err ( |e| {
69
- e. downcast_default ( ExitCode :: USR_ILLEGAL_STATE , "failed to construct state" )
70
- } ) ?;
67
+ let state = State :: new ( rt. store ( ) ) . context ( "failed to construct state" ) ?;
71
68
rt. create ( & state) ?;
72
69
Ok ( ( ) )
73
70
}
0 commit comments