8888 Ok ( InvocationResult :: Return ( return_data) ) => {
8989 backtrace. clear ( ) ;
9090 Receipt {
91- exit_code : ExitCode :: Ok ,
91+ exit_code : ExitCode :: OK ,
9292 return_data,
9393 gas_used,
9494 }
@@ -104,16 +104,19 @@ where
104104 }
105105 }
106106 Err ( ExecutionError :: OutOfGas ) => Receipt {
107- exit_code : ExitCode :: SysErrOutOfGas ,
107+ exit_code : ExitCode :: SYS_OUT_OF_GAS ,
108108 return_data : Default :: default ( ) ,
109109 gas_used,
110110 } ,
111111 Err ( ExecutionError :: Syscall ( err) ) => {
112+ // Errors indicate the message couldn't be dispatched at all.
113+ // Some of these errors are mapped to exit codes that persist on chain.
114+ // The remainder propagate in the Result as error numbers and cannot be persisted.
115+ // TODO: map them all to exit codes, https://github.com/filecoin-project/ref-fvm/issues/438
112116 let exit_code = match err. 1 {
113- ErrorNumber :: IllegalOperation => ExitCode :: SysErrIllegalActor ,
114- ErrorNumber :: AssertionFailed => ExitCode :: SysErrIllegalArgument ,
115- ErrorNumber :: InsufficientFunds => ExitCode :: SysErrInsufficientFunds ,
116- ErrorNumber :: NotFound => ExitCode :: SysErrInvalidReceiver ,
117+ ErrorNumber :: AssertionFailed => ExitCode :: SYS_ASSERTION_FAILED ,
118+ ErrorNumber :: InsufficientFunds => ExitCode :: SYS_INSUFFICIENT_FUNDS ,
119+ ErrorNumber :: NotFound => ExitCode :: SYS_INVALID_RECEIVER ,
117120 code => {
118121 return Err ( anyhow ! (
119122 "unexpected syscall error when processing message: {} ({})" ,
@@ -207,7 +210,7 @@ where
207210 // Verify the cost of the message is not over the message gas limit.
208211 if inclusion_total > msg. gas_limit {
209212 return Ok ( Err ( ApplyRet :: prevalidation_fail (
210- ExitCode :: SysErrOutOfGas ,
213+ ExitCode :: SYS_OUT_OF_GAS ,
211214 format ! ( "Out of gas ({} > {})" , inclusion_total, msg. gas_limit) ,
212215 & self . context ( ) . base_fee * inclusion_total,
213216 ) ) ) ;
@@ -227,7 +230,7 @@ where
227230 Some ( id) => id,
228231 None => {
229232 return Ok ( Err ( ApplyRet :: prevalidation_fail (
230- ExitCode :: SysErrSenderInvalid ,
233+ ExitCode :: SYS_SENDER_INVALID ,
231234 "Sender invalid" ,
232235 miner_penalty_amount,
233236 ) ) )
@@ -246,7 +249,7 @@ where
246249 Some ( act) => act,
247250 None => {
248251 return Ok ( Err ( ApplyRet :: prevalidation_fail (
249- ExitCode :: SysErrSenderInvalid ,
252+ ExitCode :: SYS_SENDER_INVALID ,
250253 "Sender invalid" ,
251254 miner_penalty_amount,
252255 ) ) )
@@ -262,7 +265,7 @@ where
262265
263266 if !sender_is_account {
264267 return Ok ( Err ( ApplyRet :: prevalidation_fail (
265- ExitCode :: SysErrSenderInvalid ,
268+ ExitCode :: SYS_SENDER_INVALID ,
266269 "Send not from account actor" ,
267270 miner_penalty_amount,
268271 ) ) ) ;
@@ -271,7 +274,7 @@ where
271274 // Check sequence is correct
272275 if msg. sequence != sender. sequence {
273276 return Ok ( Err ( ApplyRet :: prevalidation_fail (
274- ExitCode :: SysErrSenderStateInvalid ,
277+ ExitCode :: SYS_SENDER_STATE_INVALID ,
275278 format ! (
276279 "Actor sequence invalid: {} != {}" ,
277280 msg. sequence, sender. sequence
@@ -284,7 +287,7 @@ where
284287 let gas_cost: TokenAmount = msg. gas_fee_cap . clone ( ) * msg. gas_limit ;
285288 if sender. balance < gas_cost {
286289 return Ok ( Err ( ApplyRet :: prevalidation_fail (
287- ExitCode :: SysErrSenderStateInvalid ,
290+ ExitCode :: SYS_SENDER_STATE_INVALID ,
288291 format ! (
289292 "Actor balance less than needed: {} < {}" ,
290293 sender. balance, gas_cost
0 commit comments