@@ -625,7 +625,14 @@ impl ExecutorV2 {
625625 "Couldn't find an active version for smart contract under path {:?}" ,
626626 [ & vm1_key, & smart_contract_key]
627627 ) ;
628- return Err ( ExecuteError :: NoActiveContract ( smart_contract_key) ) ;
628+ return Ok ( ExecuteResult {
629+ host_error : Some ( CallError :: NoActiveContract ) ,
630+ output : None ,
631+ gas_usage : GasUsage :: new ( gas_limit, gas_limit) ,
632+ effects : tracking_copy. effects ( ) ,
633+ cache : tracking_copy. cache ( ) ,
634+ messages : tracking_copy. messages ( ) ,
635+ } ) ;
629636 } ;
630637 let entity_addr = EntityAddr :: SmartContract ( contract_hash. value ( ) ) ;
631638 let latest_version_key = Key :: AddressableEntity ( entity_addr) ;
@@ -648,7 +655,14 @@ impl ExecutorV2 {
648655 "Couldn't find an active version for smart contract under path {:?}" ,
649656 [ & vm1_key, & smart_contract_key]
650657 ) ;
651- return Err ( ExecuteError :: NoActiveContract ( smart_contract_key) ) ;
658+ return Ok ( ExecuteResult {
659+ host_error : Some ( CallError :: NoActiveContract ) ,
660+ output : None ,
661+ gas_usage : GasUsage :: new ( gas_limit, gas_limit) ,
662+ effects : tracking_copy. effects ( ) ,
663+ cache : tracking_copy. cache ( ) ,
664+ messages : tracking_copy. messages ( ) ,
665+ } ) ;
652666 } ;
653667 let latest_version_key = Key :: Hash ( contract_hash. value ( ) ) ;
654668 tracking_copy
@@ -702,15 +716,27 @@ impl ExecutorV2 {
702716 // Note: Bytecode stored in the GlobalStateReader has a "kind" option -
703717 // currently we know we have a v2 bytecode as the stored contract is of "V2"
704718 // variant.
705- let wasm_bytes = tracking_copy
706- . read ( & wasm_key)
707- . map_err ( |read_err| {
719+ let stored_value =
720+ match tracking_copy. read ( & wasm_key) . map_err ( |read_err| {
708721 error ! (
709722 "Error when fetching wasm_bytes {wasm_key}. Details {read_err}"
710723 ) ;
711724 ExecuteError :: Fatal ( FatalHostError :: TrackingCopy )
712- } ) ?
713- . ok_or ( ExecuteError :: EntityNotFound ( wasm_key) ) ?
725+ } ) ? {
726+ None => {
727+ return Ok ( ExecuteResult {
728+ host_error : Some ( CallError :: CodeNotFound ) ,
729+ output : None ,
730+ gas_usage : GasUsage :: new ( gas_limit, gas_limit) ,
731+ effects : tracking_copy. effects ( ) ,
732+ cache : tracking_copy. cache ( ) ,
733+ messages : tracking_copy. messages ( ) ,
734+ } ) ;
735+ }
736+ Some ( stored_value) => stored_value,
737+ } ;
738+
739+ let wasm_bytes = stored_value
714740 . into_byte_code ( )
715741 . ok_or ( {
716742 error ! ( "Couldn't wasm stored value into ByteCode" ) ;
@@ -726,7 +752,14 @@ impl ExecutorV2 {
726752 match tracking_copy. runtime_footprint_by_entity_addr ( entity_addr) {
727753 Ok ( footprint) => footprint,
728754 Err ( _) => {
729- return Err ( ExecuteError :: EntityNotFound ( caller_key) ) ;
755+ return Ok ( ExecuteResult {
756+ host_error : Some ( CallError :: EntityNotFound ) ,
757+ output : None ,
758+ gas_usage : GasUsage :: new ( gas_limit, gas_limit) ,
759+ effects : tracking_copy. effects ( ) ,
760+ cache : tracking_copy. cache ( ) ,
761+ messages : tracking_copy. messages ( ) ,
762+ } ) ;
730763 }
731764 } ;
732765 match system:: transfer (
@@ -799,7 +832,14 @@ impl ExecutorV2 {
799832 {
800833 Ok ( footprint) => footprint,
801834 Err ( _) => {
802- return Err ( ExecuteError :: EntityNotFound ( caller_key) ) ;
835+ return Ok ( ExecuteResult {
836+ host_error : Some ( CallError :: CodeNotFound ) ,
837+ output : None ,
838+ gas_usage,
839+ effects : tracking_copy. effects ( ) ,
840+ cache : tracking_copy. cache ( ) ,
841+ messages : tracking_copy. messages ( ) ,
842+ } ) ;
803843 }
804844 } ;
805845
@@ -898,7 +938,14 @@ impl ExecutorV2 {
898938 ?execution_kind,
899939 "No contract code found" ,
900940 ) ;
901- return Err ( ExecuteError :: CodeNotFound ( * contract_package_addr) ) ;
941+ return Ok ( ExecuteResult {
942+ host_error : Some ( CallError :: CodeNotFound ) ,
943+ output : None ,
944+ gas_usage : GasUsage :: new ( gas_limit, gas_limit) ,
945+ effects : tracking_copy. effects ( ) ,
946+ cache : tracking_copy. cache ( ) ,
947+ messages : tracking_copy. messages ( ) ,
948+ } ) ;
902949 }
903950 }
904951 } else {
@@ -1425,6 +1472,10 @@ impl Executor for ExecutorV2 {
14251472 CallError :: CalleeTrapped ( _) => SandboxedExecutionError :: CalleeTrapped ,
14261473 CallError :: CalleeGasDepleted => SandboxedExecutionError :: CalleeGasDepleted ,
14271474 CallError :: NotCallable => SandboxedExecutionError :: NotCallable ,
1475+ CallError :: NoActiveContract => SandboxedExecutionError :: NoActiveContract ,
1476+ CallError :: CodeNotFound => SandboxedExecutionError :: CodeNotFound ,
1477+ CallError :: EntityNotFound => SandboxedExecutionError :: EntityNotFound ,
1478+ CallError :: LockedPackage => SandboxedExecutionError :: LockedPackage ,
14281479 CallError :: Api ( api_error) => SandboxedExecutionError :: Api ( api_error) ,
14291480 CallError :: InputInvalid => SandboxedExecutionError :: InputInvalid ,
14301481 } ) ,
@@ -1443,7 +1494,7 @@ fn get_purse_for_entity<R: GlobalStateReader>(
14431494 let stored_value = tracking_copy
14441495 . read ( & caller_key)
14451496 . map_err ( |_error| ExecuteError :: Fatal ( FatalHostError :: TrackingCopy ) ) ?
1446- . ok_or ( ExecuteError :: EntityNotFound ( caller_key) ) ?;
1497+ . ok_or ( ExecuteError :: MainPurseNotFound ( caller_key) ) ?;
14471498 match stored_value {
14481499 StoredValue :: CLValue ( addressable_entity_key) => {
14491500 let key = addressable_entity_key. into_t :: < Key > ( ) . map_err ( |cl_error| {
@@ -1452,7 +1503,7 @@ fn get_purse_for_entity<R: GlobalStateReader>(
14521503 } ) ?;
14531504 let hash = match key. into_entity_hash ( ) {
14541505 Some ( hash) => hash,
1455- None => return Err ( ExecuteError :: EntityNotFound ( key) ) ,
1506+ None => return Err ( ExecuteError :: MainPurseNotFound ( key) ) ,
14561507 } ;
14571508 let stored_value = tracking_copy
14581509 . read ( & key)
@@ -1483,7 +1534,7 @@ fn get_purse_for_entity<R: GlobalStateReader>(
14831534 contract_hash
14841535 } else {
14851536 debug ! ( "Couldn't find an active version for smart contract {caller_key}" ) ;
1486- return Err ( ExecuteError :: NoActiveContract ( caller_key) ) ;
1537+ return Err ( ExecuteError :: MainPurseNotFound ( caller_key) ) ;
14871538 } ;
14881539
14891540 let entity_addr = EntityAddr :: SmartContract ( contract_hash. value ( ) ) ;
@@ -1495,7 +1546,7 @@ fn get_purse_for_entity<R: GlobalStateReader>(
14951546 ExecuteError :: Fatal ( FatalHostError :: TrackingCopy )
14961547 } ) ?;
14971548 let addressable_entity = stored_value
1498- . ok_or ( ExecuteError :: EntityNotFound ( latest_version_key) ) ?
1549+ . ok_or ( ExecuteError :: MainPurseNotFound ( latest_version_key) ) ?
14991550 . into_addressable_entity ( )
15001551 . ok_or ( ExecuteError :: Fatal ( FatalHostError :: TypeConversion ) ) ?;
15011552
@@ -1504,13 +1555,13 @@ fn get_purse_for_entity<R: GlobalStateReader>(
15041555 StoredValue :: ContractPackage ( contract_package) => {
15051556 let contract_hash = match contract_package. enabled_versions ( ) . last_key_value ( ) {
15061557 Some ( ( _, contract_hash) ) => Key :: Hash ( contract_hash. value ( ) ) ,
1507- None => return Err ( ExecuteError :: NoActiveContract ( caller_key) ) ,
1558+ None => return Err ( ExecuteError :: MainPurseNotFound ( caller_key) ) ,
15081559 } ;
15091560
15101561 let named_keys = tracking_copy
15111562 . read ( & contract_hash)
15121563 . map_err ( |_error| ExecuteError :: Fatal ( FatalHostError :: TrackingCopy ) ) ?
1513- . ok_or ( ExecuteError :: EntityNotFound ( contract_hash) ) ?
1564+ . ok_or ( ExecuteError :: MainPurseNotFound ( contract_hash) ) ?
15141565 . into_contract ( )
15151566 . map ( |contract| contract. take_named_keys ( ) )
15161567 . ok_or ( ExecuteError :: InvalidKeyForPurse ( contract_hash) ) ?;
@@ -1523,7 +1574,7 @@ fn get_purse_for_entity<R: GlobalStateReader>(
15231574
15241575 let hash_addr = contract_hash
15251576 . into_entity_hash_addr ( )
1526- . ok_or ( ExecuteError :: EntityNotFound ( contract_hash) ) ?;
1577+ . ok_or ( ExecuteError :: MainPurseNotFound ( contract_hash) ) ?;
15271578
15281579 Ok ( ( EntityAddr :: SmartContract ( hash_addr) , uref) )
15291580 }
0 commit comments