88
88
Ok ( InvocationResult :: Return ( return_data) ) => {
89
89
backtrace. clear ( ) ;
90
90
Receipt {
91
- exit_code : ExitCode :: Ok ,
91
+ exit_code : ExitCode :: OK ,
92
92
return_data,
93
93
gas_used,
94
94
}
@@ -104,16 +104,19 @@ where
104
104
}
105
105
}
106
106
Err ( ExecutionError :: OutOfGas ) => Receipt {
107
- exit_code : ExitCode :: SysErrOutOfGas ,
107
+ exit_code : ExitCode :: SYS_OUT_OF_GAS ,
108
108
return_data : Default :: default ( ) ,
109
109
gas_used,
110
110
} ,
111
111
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
112
116
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 ,
117
120
code => {
118
121
return Err ( anyhow ! (
119
122
"unexpected syscall error when processing message: {} ({})" ,
@@ -207,7 +210,7 @@ where
207
210
// Verify the cost of the message is not over the message gas limit.
208
211
if inclusion_total > msg. gas_limit {
209
212
return Ok ( Err ( ApplyRet :: prevalidation_fail (
210
- ExitCode :: SysErrOutOfGas ,
213
+ ExitCode :: SYS_OUT_OF_GAS ,
211
214
format ! ( "Out of gas ({} > {})" , inclusion_total, msg. gas_limit) ,
212
215
& self . context ( ) . base_fee * inclusion_total,
213
216
) ) ) ;
@@ -227,7 +230,7 @@ where
227
230
Some ( id) => id,
228
231
None => {
229
232
return Ok ( Err ( ApplyRet :: prevalidation_fail (
230
- ExitCode :: SysErrSenderInvalid ,
233
+ ExitCode :: SYS_SENDER_INVALID ,
231
234
"Sender invalid" ,
232
235
miner_penalty_amount,
233
236
) ) )
@@ -246,7 +249,7 @@ where
246
249
Some ( act) => act,
247
250
None => {
248
251
return Ok ( Err ( ApplyRet :: prevalidation_fail (
249
- ExitCode :: SysErrSenderInvalid ,
252
+ ExitCode :: SYS_SENDER_INVALID ,
250
253
"Sender invalid" ,
251
254
miner_penalty_amount,
252
255
) ) )
@@ -262,7 +265,7 @@ where
262
265
263
266
if !sender_is_account {
264
267
return Ok ( Err ( ApplyRet :: prevalidation_fail (
265
- ExitCode :: SysErrSenderInvalid ,
268
+ ExitCode :: SYS_SENDER_INVALID ,
266
269
"Send not from account actor" ,
267
270
miner_penalty_amount,
268
271
) ) ) ;
@@ -271,7 +274,7 @@ where
271
274
// Check sequence is correct
272
275
if msg. sequence != sender. sequence {
273
276
return Ok ( Err ( ApplyRet :: prevalidation_fail (
274
- ExitCode :: SysErrSenderStateInvalid ,
277
+ ExitCode :: SYS_SENDER_STATE_INVALID ,
275
278
format ! (
276
279
"Actor sequence invalid: {} != {}" ,
277
280
msg. sequence, sender. sequence
@@ -284,7 +287,7 @@ where
284
287
let gas_cost: TokenAmount = msg. gas_fee_cap . clone ( ) * msg. gas_limit ;
285
288
if sender. balance < gas_cost {
286
289
return Ok ( Err ( ApplyRet :: prevalidation_fail (
287
- ExitCode :: SysErrSenderStateInvalid ,
290
+ ExitCode :: SYS_SENDER_STATE_INVALID ,
288
291
format ! (
289
292
"Actor balance less than needed: {} < {}" ,
290
293
sender. balance, gas_cost
0 commit comments