@@ -197,28 +197,28 @@ pub fn call_generic<RT: Runtime>(
197
197
& [ ]
198
198
} ;
199
199
200
- ' early_ret: {
201
- if precompiles:: Precompiles :: < RT > :: is_precompile ( & dst) {
202
- let context = PrecompileContext {
203
- is_static : matches ! ( kind, CallKind :: StaticCall ) || system. readonly ,
204
- gas,
205
- value,
206
- } ;
200
+ if precompiles:: Precompiles :: < RT > :: is_precompile ( & dst) {
201
+ let context = PrecompileContext {
202
+ is_static : matches ! ( kind, CallKind :: StaticCall ) || system. readonly ,
203
+ gas,
204
+ value,
205
+ } ;
207
206
208
- match precompiles:: Precompiles :: call_precompile ( system. rt , dst, input_data, context)
209
- . map_err ( StatusCode :: from)
210
- {
211
- Ok ( return_data) => ( 1 , return_data) ,
212
- Err ( status) => {
213
- let msg = format ! ( "{}" , status) ;
214
- ( 0 , msg. as_bytes ( ) . to_vec ( ) )
215
- }
207
+ match precompiles:: Precompiles :: call_precompile ( system. rt , dst, input_data, context)
208
+ . map_err ( StatusCode :: from)
209
+ {
210
+ Ok ( return_data) => ( 1 , return_data) ,
211
+ Err ( status) => {
212
+ let msg = format ! ( "{}" , status) ;
213
+ ( 0 , msg. as_bytes ( ) . to_vec ( ) )
216
214
}
217
- } else {
218
- let dst_addr: EthAddress = dst. into ( ) ;
219
- let dst_addr: Address = dst_addr. try_into ( ) . expect ( "address is a precompile" ) ;
215
+ }
216
+ } else {
217
+ let dst_addr: EthAddress = dst. into ( ) ;
218
+ let dst_addr: Address = dst_addr. try_into ( ) . expect ( "address is a precompile" ) ;
220
219
221
- let call_result = match kind {
220
+ let call_result = ( || {
221
+ match kind {
222
222
CallKind :: Call | CallKind :: StaticCall => {
223
223
// Special casing for account/embryo/non-existent actors: we just do a SEND (method 0)
224
224
// which allows us to transfer funds (and create embryos)
@@ -271,17 +271,17 @@ pub fn call_generic<RT: Runtime>(
271
271
{
272
272
Some ( cid) => cid,
273
273
// failure to find CID is flattened to an empty return
274
- None => break ' early_ret ( 1 , vec ! [ ] ) ,
274
+ None => return Ok ( RawBytes :: default ( ) ) ,
275
275
} ;
276
276
277
277
let code = match system. rt . resolve_builtin_actor_type ( & cid) {
278
- Some ( Type :: EVM ) => system. rt
279
- . send ( & dst_addr, crate :: Method :: GetBytecode as u64 , Default :: default ( ) , TokenAmount :: zero ( ) ) ?
280
- . deserialize ( ) ?
281
- ,
282
- // other builtin actors & native actors
283
- _ => todo ! ( "revert when calling delegate call for native actors" )
284
- } ;
278
+ Some ( Type :: EVM ) => system. rt
279
+ . send ( & dst_addr, crate :: Method :: GetBytecode as u64 , Default :: default ( ) , TokenAmount :: zero ( ) ) ?
280
+ . deserialize ( ) ?
281
+ ,
282
+ // other builtin actors & native actors
283
+ _ => todo ! ( "revert when calling delegate call for native actors" )
284
+ } ;
285
285
286
286
// and then invoke self with delegate; readonly context is sticky
287
287
let params = DelegateCallParams {
@@ -301,21 +301,21 @@ pub fn call_generic<RT: Runtime>(
301
301
EVM_CONTRACT_EXECUTION_ERROR ,
302
302
"unsupported opcode" . to_string ( ) ,
303
303
) ) ,
304
- } ;
305
- match call_result {
306
- Ok ( result ) => {
307
- // Support the "empty" result. We often use this to mean "returned nothing" and
308
- // it's important to support, e.g., sending to accounts.
309
- if result . is_empty ( ) {
310
- ( 1 , Vec :: new ( ) )
311
- } else {
312
- // TODO: support IPLD codecs #758
313
- let BytesDe ( result ) = result . deserialize ( ) ? ;
314
- ( 1 , result)
315
- }
304
+ }
305
+ } ) ( ) ;
306
+ match call_result {
307
+ Ok ( result) => {
308
+ // Support the "empty" result. We often use this to mean "returned nothing" and
309
+ // it's important to support, e.g., sending to accounts.
310
+ if result . is_empty ( ) {
311
+ ( 1 , Vec :: new ( ) )
312
+ } else {
313
+ // TODO: support IPLD codecs #758
314
+ let BytesDe ( result ) = result. deserialize ( ) ? ;
315
+ ( 1 , result )
316
316
}
317
- Err ( ae) => ( 0 , ae. data ( ) . to_vec ( ) ) ,
318
317
}
318
+ Err ( ae) => ( 0 , ae. data ( ) . to_vec ( ) ) ,
319
319
}
320
320
}
321
321
} ;
0 commit comments