Browse Source

Bump polkadot node version (#1617)

Upgrade the Polkadot node. In recent versions, the node (in debug mode)
logs any API calls and their results to debug buffer on its own. Removed
this feature because it was only relevant in the Polkadot target.
Cyrill Leutwiler 1 year ago
parent
commit
0f032dcec2

+ 2 - 2
.github/workflows/test.yml

@@ -348,7 +348,7 @@ jobs:
       # We can't run substrate node as a github actions service, since it requires
       # command line arguments. See https://github.com/actions/runner/pull/1152
     - name: Start substrate contracts node
-      run: echo id=$(docker run -d -p 9944:9944 ghcr.io/hyperledger/solang-substrate-ci:054bef6 substrate-contracts-node --dev --rpc-external) >> $GITHUB_OUTPUT
+      run: echo id=$(docker run -d -p 9944:9944 ghcr.io/hyperledger/solang-substrate-ci:ad6da01 substrate-contracts-node --dev --rpc-external -lwarn,runtime::contracts=trace) >> $GITHUB_OUTPUT
       id: substrate
     - uses: actions/download-artifact@v3
       with:
@@ -390,7 +390,7 @@ jobs:
       # We can't run substrate node as a github actions service, since it requires
       # command line arguments. See https://github.com/actions/runner/pull/1152
     - name: Start substrate
-      run: echo id=$(docker run -d -p 9944:9944 ghcr.io/hyperledger/solang-substrate-ci:054bef6 substrate-contracts-node --dev --rpc-external) >> $GITHUB_OUTPUT
+      run: echo id=$(docker run -d -p 9944:9944 ghcr.io/hyperledger/solang-substrate-ci:ad6da01 substrate-contracts-node --dev --rpc-external -lwarn,runtime::contracts=trace) >> $GITHUB_OUTPUT
       id: substrate
     - uses: actions/download-artifact@v3
       with:

+ 1 - 0
CHANGELOG.md

@@ -12,6 +12,7 @@ will be documented here.
 ### Changed
 - **BREAKING** The non-standard extension of concatenating strings using the `+` operator
   has been removed, use `string.concat()` instead. [seanyoung](https://github.com/seanyoung)
+- Removed the `--no-log-api-return-codes` compile flag as this is now done by the runtime [xermicus](https://github.com/xermicus)
 
 ## v0.3.3 Atlantis
 

+ 0 - 15
docs/code_gen_options.rst

@@ -177,21 +177,6 @@ Print Function
 Solang provides a :ref:`print_function` which is enabled by default.
 The ``no-print`` flag will instruct the compiler not to log debugging prints in the environment.
 
-.. _no-log-api-return-codes:
-
-Log runtime API call results
-++++++++++++++++++++++++++++
-
-Runtime API calls are not guaranteed to succeed.
-By design, the low level results of these calls are abstracted away in Solidity.
-For development purposes, it can be desirable to observe the low level return code of such calls.
-The contract will print the return code of runtime calls by default, and this feature can be disabled by providing the 
-``--no-log-api-return-codes`` flag.
-
-.. note::
-
-    This is only implemented for the Polkadot target.
-
 
 .. _no-log-runtime-errors:
 

+ 0 - 3
docs/running.rst

@@ -119,9 +119,6 @@ Options:
 \-\-no\-cse
    Disable the :ref:`common-subexpression-elimination` optimization
 
-\-\-no\-log\-api\-return\-codes
-   Disable the :ref:`no-log-api-return-codes` debugging feature
-
 \-\-no\-log\-runtime\-errors
    Disable the :ref:`no-log-runtime-errors` debugging feature
 

+ 4 - 1
integration/polkadot/balances.spec.ts

@@ -28,7 +28,10 @@ describe('Deploy balances contract and test', () => {
         let { output: contractRpcBal } = await query(conn, alice, contract, "getBalance");
         let { data: { free: contractQueryBalBefore } } = await conn.query.system.account(String(deploy_contract.address));
 
-        expect(contractRpcBal?.toString()).toBe(contractQueryBalBefore.toString());
+        // The "Existential Deposit" (aka. minimum balance) is part of the free balance;
+        // to get the actual free balance from a contracts point of view we substract it.
+        const ED = 1000000000n;
+        expect(contractRpcBal?.toString()).toBe((contractQueryBalBefore.toBigInt() - ED).toString());
 
         let gasLimit = await weight(conn, contract, "payMe", undefined, 1000000n);
         let tx = contract.tx.payMe({ gasLimit, value: 1000000n });

+ 1 - 1
integration/polkadot/chain_extension.spec.ts

@@ -1,5 +1,5 @@
 import expect from 'expect';
-import { weight, createConnection, deploy, transaction, aliceKeypair, query, } from './index';
+import { createConnection, deploy, aliceKeypair, query, } from './index';
 import { ContractPromise } from '@polkadot/api-contract';
 import { daveKeypair } from './index';
 

+ 8 - 5
integration/polkadot/create_contract.spec.ts

@@ -29,8 +29,8 @@ describe('Deploy create_contract contract and test', () => {
 
         let dry = await dry_run(conn, contract, "createChild");
         // Expect the instantiation nonce to be present
-        const current_nonce = dry.debugMessage.split('\n')[0].split('=');
-        expect(current_nonce[0]).toEqual("call: instantiation_nonce");
+        const current_nonce = dry.debugMessage.split('\n')[2].split('=');
+        expect(current_nonce[0]).toContain("seal0::instantiation_nonce");
 
         const gasLimit = dry.gasRequired;
         let tx = contract.tx.createChild({ gasLimit });
@@ -51,8 +51,11 @@ describe('Deploy create_contract contract and test', () => {
         expect(BigInt(1e15) - childBalance.toBigInt()).toBeLessThan(1e11);
 
         // Expect the instantiation nonce to be present and to increase
-        const next_nonce = (await debug_buffer(conn, contract, "createChild")).split('\n')[0].split('=');
-        expect(next_nonce[0]).toEqual("call: instantiation_nonce");
-        expect(parseInt(current_nonce[1])).toBeLessThan(parseInt(next_nonce[1]));
+        const next_nonce = (await debug_buffer(conn, contract, "createChild")).split('\n')[2].split('=');
+        expect(next_nonce[0]).toContain("seal0::instantiation_nonce");
+
+        const current_nonce_value = parseInt(current_nonce[1].split('(')[1].split(')')[0]);
+        const next_nonce_value = parseInt(next_nonce[1].split('(')[1].split(')')[0]);
+        expect(current_nonce_value).toBeLessThan(next_nonce_value);
     });
 });

+ 4 - 12
integration/polkadot/debug_buffer_format.spec.ts

@@ -22,20 +22,12 @@ describe('Deploy debug_buffer_format.sol and test the debug buffer formatting',
         );
 
         let res = await debug_buffer(conn, contract, "multiple_prints", [])
-        expect(res).toEqual(`print: Hello!,
-call: seal_debug_message=0,
-print: I call seal_debug_message under the hood!,
-call: seal_debug_message=0,
-`)
+        expect(res).toContain(`print: Hello!,`);
+        expect(res).toContain(`print: I call seal_debug_message under the hood!,`);
 
         let res1 = await debug_buffer(conn, contract, "multiple_prints_then_revert", [])
-        expect(res1).toEqual(`print: Hello!,
-call: seal_debug_message=0,
-print: I call seal_debug_message under the hood!,
-call: seal_debug_message=0,
-runtime_error: sesa!!! revert encountered in debug_buffer_format.sol:10:9-26,
-call: seal_debug_message=0,
-`)
+        expect(res1).toContain(`print: Hello!,`);
+        expect(res1).toContain(`print: I call seal_debug_message under the hood!,`);
 
         conn.disconnect();
     });

+ 2 - 2
integration/polkadot/ink/caller/Cargo.toml

@@ -5,10 +5,10 @@ authors = ["Cyrill Leutwiler <cyrill@parity.io>"]
 edition = "2021"
 
 [dependencies]
-ink = { version = "4.2.0", default-features = false }
+ink = { version = "4.3.0", default-features = false }
 
 scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
-scale-info = { version = "2.6", default-features = false, features = ["derive"], optional = true }
+scale-info = { version = "2.10", default-features = false, features = ["derive"], optional = true }
 
 [lib]
 path = "lib.rs"

+ 6 - 6
integration/polkadot/package.json

@@ -6,7 +6,7 @@
   "scripts": {
     "test": "tsc; ts-mocha -t 20000 --exit *.spec.ts",
     "build": "./build.sh",
-    "build-ink": "docker run --rm -v $(pwd)/ink/caller:/opt/contract ghcr.io/hyperledger/solang-substrate-ci:054bef6 cargo contract build --release --manifest-path /opt/contract/Cargo.toml"
+    "build-ink": "docker run --rm -v $(pwd)/ink/caller:/opt/contract ghcr.io/hyperledger/solang-substrate-ci:ad6da01 cargo contract build --release --manifest-path /opt/contract/Cargo.toml"
   },
   "contributors": [
     {
@@ -30,11 +30,11 @@
     "typescript": "^4.7"
   },
   "dependencies": {
-    "@polkadot/api": "^10.9",
-    "@polkadot/api-contract": "^10.9",
-    "@polkadot/keyring": "^12.3",
-    "@polkadot/types": "^10.9",
-    "@polkadot/util-crypto": "^12.3",
+    "@polkadot/api": "^10.11",
+    "@polkadot/api-contract": "^10.11",
+    "@polkadot/keyring": "^12.6",
+    "@polkadot/types": "^10.11",
+    "@polkadot/util-crypto": "^12.6",
     "websnark": "git+https://github.com/tornadocash/websnark.git#4c0af6a8b65aabea3c09f377f63c44e7a58afa6d",
     "snarkjs": "git+https://github.com/tornadocash/snarkjs.git#869181cfaf7526fe8972073d31655493a04326d5",
     "circomlib": "git+https://github.com/tornadocash/circomlib.git#c372f14d324d57339c88451834bf2824e73bbdbc",

+ 2 - 2
integration/polkadot/release_version.spec.ts

@@ -20,10 +20,10 @@ describe('Deploy release_version.sol and test the debug buffer is empty', () =>
 
         // The --release flag should remove all debugging features, making the debug buffer empty
         let res = await debug_buffer(conn, contract, `print_then_error`, [20])
-        expect(res).toEqual("")
+        expect(res).not.toContain("Hello!")
 
         let res2 = await debug_buffer(conn, contract, `print_then_error`, [0])
-        expect(res2).toEqual("")
+        expect(res).not.toContain("Hello!")
         conn.disconnect();
     });
 });

+ 1 - 1
integration/subxt-tests/Cargo.toml

@@ -14,7 +14,7 @@ pallet-contracts-primitives = "24.0.0"
 hex = "0.4.3"
 num-bigint = "0.4.3"
 once_cell = "1.17.2"
-parity-scale-codec = {  version = "3.5.0", features = ["derive"] }
+parity-scale-codec = {  version = "3.6.9", features = ["derive"] }
 rand = "0.8.5"
 serde_json = "1.0.96"
 sp-keyring = "24.0.0"

BIN
integration/subxt-tests/metadata.scale


+ 6 - 1
integration/subxt-tests/src/cases/destruct.rs

@@ -68,7 +68,12 @@ async fn case() -> anyhow::Result<()> {
     let contract_after = free_balance_of(&api, deployed.contract_address.clone()).await?;
 
     assert_eq!(contract_after, 0);
-    assert_eq!(dave_after, dave_before + contract_before);
+
+    let existential_deposit = 1000000000;
+    assert_eq!(
+        dave_after,
+        dave_before + contract_before + existential_deposit
+    );
 
     Ok(())
 }

+ 1 - 1
integration/subxt-tests/src/lib.rs

@@ -412,7 +412,7 @@ pub async fn free_balance_of(api: &API, addr: AccountId32) -> anyhow::Result<u12
         .fetch_or_default(&key)
         .await?;
 
-    Ok(val.data.free)
+    Ok(val.data.free.saturating_sub(1000000000))
 }
 
 struct Contract {

+ 0 - 10
src/bin/cli/mod.rs

@@ -180,10 +180,6 @@ impl Compile {
                 }
 
                 // DebugFeatures args
-                "NOLOGAPIRETURNS" => {
-                    self.debug_features.log_api_return_codes =
-                        *matches.get_one::<bool>("NOLOGAPIRETURNS").unwrap()
-                }
                 "NOLOGRUNTIMEERRORS" => {
                     self.debug_features.log_runtime_errors =
                         *matches.get_one::<bool>("NOLOGRUNTIMEERRORS").unwrap()
@@ -329,10 +325,6 @@ pub struct CompilePackage {
 
 #[derive(Args, Deserialize, Debug, PartialEq)]
 pub struct DebugFeatures {
-    #[arg(name = "NOLOGAPIRETURNS", help = "Disable logging the return codes of runtime API calls in the environment", long = "no-log-api-return-codes", action = ArgAction::SetFalse)]
-    #[serde(default, rename(deserialize = "log-api-return-codes"))]
-    pub log_api_return_codes: bool,
-
     #[arg(name = "NOLOGRUNTIMEERRORS", help = "Disable logging runtime errors in the environment", long = "no-log-runtime-errors", action = ArgAction::SetFalse)]
     #[serde(default, rename(deserialize = "log-runtime-errors"))]
     pub log_runtime_errors: bool,
@@ -353,7 +345,6 @@ pub struct DebugFeatures {
 impl Default for DebugFeatures {
     fn default() -> Self {
         DebugFeatures {
-            log_api_return_codes: true,
             log_runtime_errors: true,
             log_prints: true,
             generate_debug_info: false,
@@ -575,7 +566,6 @@ pub fn options_arg(debug: &DebugFeatures, optimizations: &Optimizations) -> Opti
         common_subexpression_elimination: optimizations.common_subexpression_elimination,
         generate_debug_information: debug.generate_debug_info,
         opt_level,
-        log_api_return_codes: debug.log_api_return_codes && !debug.release,
         log_runtime_errors: debug.log_runtime_errors && !debug.release,
         log_prints: debug.log_prints && !debug.release,
         #[cfg(feature = "wasm_opt")]

+ 1 - 4
src/bin/cli/test.rs

@@ -34,12 +34,11 @@ mod tests {
             assert_eq!(compile_args.optimizations.opt_level.unwrap(), "aggressive");
         }
 
-        command = "solang compile flipper.sol --target polkadot --no-log-runtime-errors --no-prints --no-log-api-return-codes -g --release".split(' ').collect();
+        command = "solang compile flipper.sol --target polkadot --no-log-runtime-errors --no-prints -g --release".split(' ').collect();
         cli = Cli::parse_from(command);
 
         if let Commands::Compile(compile_args) = cli.command {
             assert!(compile_args.debug_features.generate_debug_info);
-            assert!(!compile_args.debug_features.log_api_return_codes);
             assert!(!compile_args.debug_features.log_prints);
             assert!(!compile_args.debug_features.log_runtime_errors);
             assert!(compile_args.debug_features.release);
@@ -201,7 +200,6 @@ mod tests {
                     value_length: None
                 },
                 debug_features: cli::DebugFeatures {
-                    log_api_return_codes: true,
                     log_runtime_errors: true,
                     log_prints: true,
                     generate_debug_info: false,
@@ -256,7 +254,6 @@ mod tests {
                     value_length: Some(31)
                 },
                 debug_features: cli::DebugFeatures {
-                    log_api_return_codes: true,
                     log_runtime_errors: true,
                     log_prints: true,
                     generate_debug_info: false,

+ 0 - 2
src/codegen/mod.rs

@@ -103,7 +103,6 @@ pub struct Options {
     pub common_subexpression_elimination: bool,
     pub generate_debug_information: bool,
     pub opt_level: OptimizationLevel,
-    pub log_api_return_codes: bool,
     pub log_runtime_errors: bool,
     pub log_prints: bool,
     #[cfg(feature = "wasm_opt")]
@@ -120,7 +119,6 @@ impl Default for Options {
             common_subexpression_elimination: true,
             generate_debug_information: false,
             opt_level: OptimizationLevel::Default,
-            log_api_return_codes: false,
             log_runtime_errors: false,
             log_prints: true,
             #[cfg(feature = "wasm_opt")]

+ 0 - 72
src/emit/polkadot/mod.rs

@@ -12,7 +12,6 @@ use inkwell::AddressSpace;
 use crate::codegen::dispatch::polkadot::DispatchType;
 use crate::emit::functions::emit_functions;
 use crate::emit::{Binary, TargetRuntime};
-use crate::emit_context;
 
 mod storage;
 pub(super) mod target;
@@ -300,74 +299,3 @@ impl PolkadotTarget {
         bin.builder.build_unreachable();
     }
 }
-
-/// Print the return code of API calls to the debug buffer.
-fn log_return_code(binary: &Binary, api: &'static str, code: IntValue) {
-    if !binary.options.log_api_return_codes {
-        return;
-    }
-
-    emit_context!(binary);
-
-    let fmt = format!("call: {api}=");
-    let msg = fmt.as_bytes();
-    let delimiter = b",\n";
-    let delimiter_length = delimiter.len();
-    let length = i32_const!(msg.len() as u64 + 16 + delimiter_length as u64);
-    let out_buf =
-        binary
-            .builder
-            .build_array_alloca(binary.context.i8_type(), length, "seal_ret_code_buf");
-    let mut out_buf_offset = out_buf;
-
-    let msg_string = binary.emit_global_string(&fmt, msg, true);
-    let msg_len = binary.context.i32_type().const_int(msg.len() as u64, false);
-    call!(
-        "__memcpy",
-        &[out_buf_offset.into(), msg_string.into(), msg_len.into()]
-    );
-    out_buf_offset = unsafe {
-        binary
-            .builder
-            .build_gep(binary.context.i8_type(), out_buf_offset, &[msg_len], "")
-    };
-
-    let code = binary
-        .builder
-        .build_int_z_extend(code, binary.context.i64_type(), "val_64bits");
-    out_buf_offset = call!("uint2dec", &[out_buf_offset.into(), code.into()])
-        .try_as_basic_value()
-        .left()
-        .unwrap()
-        .into_pointer_value();
-
-    let delimiter_string = binary.emit_global_string("delimiter", delimiter, true);
-    let lim_len = binary
-        .context
-        .i32_type()
-        .const_int(delimiter_length as u64, false);
-    call!(
-        "__memcpy",
-        &[
-            out_buf_offset.into(),
-            delimiter_string.into(),
-            lim_len.into()
-        ]
-    );
-    out_buf_offset = unsafe {
-        binary
-            .builder
-            .build_gep(binary.context.i8_type(), out_buf_offset, &[lim_len], "")
-    };
-
-    let msg_len = binary.builder.build_int_sub(
-        binary
-            .builder
-            .build_ptr_to_int(out_buf_offset, binary.context.i32_type(), "out_buf_idx"),
-        binary
-            .builder
-            .build_ptr_to_int(out_buf, binary.context.i32_type(), "out_buf_ptr"),
-        "msg_len",
-    );
-    call!("debug_message", &[out_buf.into(), msg_len.into()]);
-}

+ 5 - 11
src/emit/polkadot/storage.rs

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: Apache-2.0
 
 use crate::emit::binary::Binary;
-use crate::emit::polkadot::{log_return_code, PolkadotTarget};
+use crate::emit::polkadot::PolkadotTarget;
 use crate::emit::storage::StorageSlot;
 use crate::emit::TargetRuntime;
 use crate::emit_context;
@@ -35,14 +35,12 @@ impl StorageSlot for PolkadotTarget {
                 .const_cast(binary.context.i32_type(), false)
         };
 
-        let ret = seal_set_storage!(
+        seal_set_storage!(
             slot.into(),
             i32_const!(32).into(),
             dest.into(),
             dest_size.into()
         );
-
-        log_return_code(binary, "seal_set_storage", ret);
     }
 
     fn get_storage_address<'a>(
@@ -66,9 +64,7 @@ impl StorageSlot for PolkadotTarget {
             scratch_len.into()
         );
 
-        log_return_code(binary, "seal_get_storage", exists);
-
-        let exists = binary.builder.build_int_compare(
+        let exists_is_zero = binary.builder.build_int_compare(
             IntPredicate::EQ,
             exists,
             i32_zero!(),
@@ -78,7 +74,7 @@ impl StorageSlot for PolkadotTarget {
         binary
             .builder
             .build_select(
-                exists,
+                exists_is_zero,
                 binary
                     .builder
                     .build_load(binary.address_type(ns), scratch_buf, "address")
@@ -92,13 +88,11 @@ impl StorageSlot for PolkadotTarget {
     fn storage_delete_single_slot(&self, binary: &Binary, slot: PointerValue) {
         emit_context!(binary);
 
-        let ret = call!("clear_storage", &[slot.into(), i32_const!(32).into()])
+        call!("clear_storage", &[slot.into(), i32_const!(32).into()])
             .try_as_basic_value()
             .left()
             .unwrap()
             .into_int_value();
-
-        log_return_code(binary, "seal_clear_storage", ret);
     }
 
     fn storage_load_slot<'a>(

+ 32 - 72
src/emit/polkadot/target.rs

@@ -4,7 +4,7 @@ use crate::codegen::cfg::HashTy;
 use crate::codegen::revert::PanicCode;
 use crate::emit::binary::Binary;
 use crate::emit::expression::expression;
-use crate::emit::polkadot::{log_return_code, PolkadotTarget, SCRATCH_SIZE};
+use crate::emit::polkadot::{PolkadotTarget, SCRATCH_SIZE};
 use crate::emit::storage::StorageSlot;
 use crate::emit::{ContractArgs, TargetRuntime, Variable};
 use crate::sema::ast;
@@ -30,7 +30,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
     ) {
         emit_context!(binary);
 
-        let ret = seal_set_storage!(
+        seal_set_storage!(
             slot.into(),
             i32_const!(32).into(),
             dest.into(),
@@ -40,8 +40,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
                 .const_cast(binary.context.i32_type(), false)
                 .into()
         );
-
-        log_return_code(binary, "seal_set_storage", ret);
     }
 
     fn get_storage_extfunc(
@@ -75,7 +73,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
             binary.context.i64_type().const_int(len as u64, false),
         );
 
-        let ret = call!(
+        call!(
             "get_storage",
             &[
                 slot.into(),
@@ -89,8 +87,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
         .unwrap()
         .into_int_value();
 
-        log_return_code(binary, "seal_get_storage: ", ret);
-
         // TODO: decide behaviour if not exist
 
         ef
@@ -124,22 +120,18 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
 
         binary.builder.position_at_end(set_block);
 
-        let ret = seal_set_storage!(slot.into(), i32_const!(32).into(), data.into(), len.into());
-
-        log_return_code(binary, "seal_set_storage", ret);
+        seal_set_storage!(slot.into(), i32_const!(32).into(), data.into(), len.into());
 
         binary.builder.build_unconditional_branch(done_storage);
 
         binary.builder.position_at_end(delete_block);
 
-        let ret = call!("clear_storage", &[slot.into(), i32_const!(32).into()])
+        call!("clear_storage", &[slot.into(), i32_const!(32).into()])
             .try_as_basic_value()
             .left()
             .unwrap()
             .into_int_value();
 
-        log_return_code(binary, "seal_clear_storage", ret);
-
         binary.builder.build_unconditional_branch(done_storage);
 
         binary.builder.position_at_end(done_storage);
@@ -166,9 +158,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
             scratch_len.into()
         );
 
-        log_return_code(binary, "seal_get_storage: ", exists);
-
-        let exists = binary.builder.build_int_compare(
+        let exists_is_zero = binary.builder.build_int_compare(
             IntPredicate::EQ,
             exists,
             i32_zero!(),
@@ -181,7 +171,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
 
         binary
             .builder
-            .build_conditional_branch(exists, retrieve_block, done_storage);
+            .build_conditional_branch(exists_is_zero, retrieve_block, done_storage);
 
         binary.builder.position_at_end(retrieve_block);
 
@@ -223,9 +213,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
             scratch_len.into()
         );
 
-        log_return_code(binary, "seal_get_storage: ", exists);
-
-        let exists = binary.builder.build_int_compare(
+        let exists_is_zero = binary.builder.build_int_compare(
             IntPredicate::EQ,
             exists,
             i32_zero!(),
@@ -248,7 +236,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
 
         binary
             .builder
-            .build_conditional_branch(exists, retrieve_block, done_storage);
+            .build_conditional_branch(exists_is_zero, retrieve_block, done_storage);
 
         binary.builder.position_at_end(retrieve_block);
 
@@ -316,9 +304,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
             scratch_len.into()
         );
 
-        log_return_code(binary, "seal_get_storage", exists);
-
-        let exists = binary.builder.build_int_compare(
+        let exists_is_zero = binary.builder.build_int_compare(
             IntPredicate::EQ,
             exists,
             i32_zero!(),
@@ -328,7 +314,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
         let length = binary
             .builder
             .build_select(
-                exists,
+                exists_is_zero,
                 binary
                     .builder
                     .build_load(binary.context.i32_type(), scratch_len, "string_len"),
@@ -406,9 +392,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
             scratch_len.into()
         );
 
-        log_return_code(binary, "seal_get_storage", exists);
-
-        let exists = binary.builder.build_int_compare(
+        let exists_is_zero = binary.builder.build_int_compare(
             IntPredicate::EQ,
             exists,
             i32_zero!(),
@@ -418,7 +402,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
         let length = binary
             .builder
             .build_select(
-                exists,
+                exists_is_zero,
                 binary
                     .builder
                     .build_load(binary.context.i32_type(), scratch_len, "string_len"),
@@ -464,14 +448,12 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
         // set the result
         binary.builder.build_store(offset, val);
 
-        let ret = seal_set_storage!(
+        seal_set_storage!(
             slot_ptr.into(),
             i32_const!(32).into(),
             scratch_buf.into(),
             length.into()
         );
-
-        log_return_code(binary, "seal_set_storage", ret);
     }
 
     /// Push a byte onto a bytes string in storage
@@ -506,9 +488,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
             scratch_len.into()
         );
 
-        log_return_code(binary, "seal_get_storage", exists);
-
-        let exists = binary.builder.build_int_compare(
+        let exists_is_zero = binary.builder.build_int_compare(
             IntPredicate::EQ,
             exists,
             i32_zero!(),
@@ -518,7 +498,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
         let length = binary
             .builder
             .build_select(
-                exists,
+                exists_is_zero,
                 binary
                     .builder
                     .build_load(binary.context.i32_type(), scratch_len, "string_len"),
@@ -544,15 +524,13 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
             .builder
             .build_int_add(length, i32_const!(1), "new_length");
 
-        let ret = seal_set_storage!(
+        seal_set_storage!(
             slot_ptr.into(),
             i32_const!(32).into(),
             scratch_buf.into(),
             length.into()
         );
 
-        log_return_code(binary, "seal_set_storage", ret);
-
         val
     }
 
@@ -585,9 +563,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
             scratch_len.into()
         );
 
-        log_return_code(binary, "seal_get_storage", exists);
-
-        let exists = binary.builder.build_int_compare(
+        let exists_is_zero = binary.builder.build_int_compare(
             IntPredicate::EQ,
             exists,
             i32_zero!(),
@@ -597,7 +573,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
         let length = binary
             .builder
             .build_select(
-                exists,
+                exists_is_zero,
                 binary
                     .builder
                     .build_load(binary.context.i32_type(), scratch_len, "string_len"),
@@ -657,15 +633,13 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
             None
         };
 
-        let ret = seal_set_storage!(
+        seal_set_storage!(
             slot_ptr.into(),
             i32_const!(32).into(),
             scratch_buf.into(),
             new_length.into()
         );
 
-        log_return_code(binary, "seal_set_storage", ret);
-
         val
     }
 
@@ -696,9 +670,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
             scratch_len.into()
         );
 
-        log_return_code(binary, "seal_get_storage", exists);
-
-        let exists = binary.builder.build_int_compare(
+        let exists_is_zero = binary.builder.build_int_compare(
             IntPredicate::EQ,
             exists,
             i32_zero!(),
@@ -708,7 +680,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
         binary
             .builder
             .build_select(
-                exists,
+                exists_is_zero,
                 binary
                     .builder
                     .build_load(binary.context.i32_type(), scratch_len, "string_len"),
@@ -789,13 +761,11 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
     fn print(&self, binary: &Binary, string_ptr: PointerValue, string_len: IntValue) {
         emit_context!(binary);
 
-        let ret = call!("debug_message", &[string_ptr.into(), string_len.into()])
+        call!("debug_message", &[string_ptr.into(), string_len.into()])
             .try_as_basic_value()
             .left()
             .unwrap()
             .into_int_value();
-
-        log_return_code(binary, "seal_debug_message", ret);
     }
 
     fn create_contract<'b>(
@@ -830,7 +800,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
                 .left()
                 .unwrap()
                 .into_int_value();
-            log_return_code(binary, "instantiation_nonce", nonce);
             let i256_t = binary.context.custom_width_int_type(256);
             binary
                 .builder
@@ -868,7 +837,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
             .builder
             .build_store(scratch_len, i32_const!(SCRATCH_SIZE as u64 * 32));
 
-        let ret = call!(
+        *success.unwrap() = call!(
             "instantiate",
             &[
                 codehash.into(),
@@ -887,11 +856,8 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
         .try_as_basic_value()
         .left()
         .unwrap()
-        .into_int_value();
-
-        log_return_code(binary, "seal_instantiate", ret);
-
-        *success.unwrap() = ret.into();
+        .into_int_value()
+        .into();
     }
 
     /// Call external binary
@@ -924,7 +890,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
                 binary
                     .builder
                     .build_store(value_ptr, contract_args.value.unwrap());
-                let ret = call!(
+                call!(
                     "seal_call",
                     &[
                         contract_args.flags.unwrap_or(i32_zero!()).into(),
@@ -940,9 +906,8 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
                 .try_as_basic_value()
                 .left()
                 .unwrap()
-                .into_int_value();
-                log_return_code(binary, "seal_call", ret);
-                ret.as_basic_value_enum()
+                .into_int_value()
+                .as_basic_value_enum()
             }
             ast::CallTy::Delegate => {
                 // delegate_call asks for a code hash instead of an address
@@ -968,7 +933,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
                 .left()
                 .unwrap()
                 .into_int_value();
-                log_return_code(binary, "seal_code_hash", code_hash_ret);
 
                 let code_hash_found = binary.builder.build_int_compare(
                     IntPredicate::EQ,
@@ -1011,7 +975,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
                 .left()
                 .unwrap()
                 .into_int_value();
-                log_return_code(binary, "seal_delegate_call", delegate_call_ret);
                 binary.builder.build_unconditional_branch(done_block);
 
                 binary.builder.position_at_end(done_block);
@@ -1045,7 +1008,7 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
         binary.builder.build_store(value_ptr, value);
 
         // do the actual call
-        let ret = call!(
+        *success.unwrap() = call!(
             "transfer",
             &[
                 address.into(),
@@ -1057,10 +1020,8 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
         .try_as_basic_value()
         .left()
         .unwrap()
-        .into_int_value();
-
-        log_return_code(binary, "seal_transfer", ret);
-        *success.unwrap() = ret.into();
+        .into_int_value()
+        .into();
     }
 
     fn return_data<'b>(&self, binary: &Binary<'b>, _function: FunctionValue) -> PointerValue<'b> {
@@ -1616,7 +1577,6 @@ impl<'a> TargetRuntime<'a> for PolkadotTarget {
                 binary
                     .builder
                     .build_store(args[1].into_pointer_value(), ret);
-                log_return_code(binary, "seal_set_code_hash", ret);
                 None
             }
             _ => unimplemented!(),

+ 4 - 5
tests/polkadot.rs

@@ -1024,14 +1024,14 @@ impl MockSubstrate {
 /// The mock runtime will contain a contract account for each contract in `src`.
 /// Constructors are _not_ called, therefore the storage will not be initialized.
 pub fn build_solidity(src: &str) -> MockSubstrate {
-    build_solidity_with_options(src, false, true)
+    build_solidity_with_options(src, true)
 }
 
 /// A variant of `MockSubstrate::uild_solidity()` with the ability to specify compiler options:
 /// * log_ret: enable logging of host function return codes
 /// * log_err: enable logging of runtime errors
-pub fn build_solidity_with_options(src: &str, log_ret: bool, log_err: bool) -> MockSubstrate {
-    let blobs = build_wasm(src, log_ret, log_err)
+pub fn build_solidity_with_options(src: &str, log_err: bool) -> MockSubstrate {
+    let blobs = build_wasm(src, log_err)
         .iter()
         .map(|(code, abi)| WasmCode::new(abi, code))
         .collect();
@@ -1039,7 +1039,7 @@ pub fn build_solidity_with_options(src: &str, log_ret: bool, log_err: bool) -> M
     MockSubstrate(Store::new(&Engine::default(), Runtime::new(blobs)))
 }
 
-pub fn build_wasm(src: &str, log_ret: bool, log_err: bool) -> Vec<(Vec<u8>, String)> {
+pub fn build_wasm(src: &str, log_err: bool) -> Vec<(Vec<u8>, String)> {
     let tmp_file = OsStr::new("test.sol");
     let mut cache = FileResolver::default();
     cache.set_file_contents(tmp_file.to_str().unwrap(), src.to_string());
@@ -1051,7 +1051,6 @@ pub fn build_wasm(src: &str, log_ret: bool, log_err: bool) -> Vec<(Vec<u8>, Stri
         target,
         &Options {
             opt_level: opt.into(),
-            log_api_return_codes: log_ret,
             log_runtime_errors: log_err,
             log_prints: true,
             #[cfg(feature = "wasm_opt")]

+ 4 - 4
tests/polkadot_tests/abi.rs

@@ -42,7 +42,7 @@ contract Mother {
     }
 }"#;
 
-    let solang_abi = load_abi(&build_wasm(src, false, false)[0].1);
+    let solang_abi = load_abi(&build_wasm(src, false)[0].1);
     let ink_str = std::fs::read_to_string("testdata/ink/mother.json").unwrap();
     let ink_abi: InkProject = serde_json::from_str(&ink_str).unwrap();
 
@@ -108,7 +108,7 @@ fn inherited_externally_callable_functions() {
     contract MyToken is ERC1155 {}
     "##;
 
-    let abi = load_abi(&build_wasm(src, false, false)[0].1);
+    let abi = load_abi(&build_wasm(src, false)[0].1);
     let messages = abi.spec().messages();
 
     assert_eq!(messages.len(), 1);
@@ -122,7 +122,7 @@ fn error_and_panic_in_lang_error() {
     let src = r##"
     contract Foo { uint public foo; }
     "##;
-    let abi = load_abi(&build_wasm(src, false, false)[0].1);
+    let abi = load_abi(&build_wasm(src, false)[0].1);
 
     // Find them in lang_error
     let (error_ty_id, panic_ty_id) = match &abi
@@ -183,7 +183,7 @@ fn custom_errors_in_metadata() {
         error Unauthorized();
         error ERC721InsufficientApproval(string operator, uint256 tokenId);
         contract VendingMachine { uint public foo; }"#;
-    let abi = load_abi(&build_wasm(src, false, false)[0].1);
+    let abi = load_abi(&build_wasm(src, false)[0].1);
 
     // Find them in lang_error
     let (error_ty_id, custom_ty_id, erc721_ty_id) = match &abi

+ 3 - 14
tests/polkadot_tests/calls.rs

@@ -860,21 +860,12 @@ fn log_api_call_return_values_works() {
             }
         }
         "#,
-        true,
         false,
     );
 
     runtime.constructor(0, vec![]);
     runtime.function("test", vec![]);
-    assert_eq!(
-        &runtime.debug_buffer(),
-        r##"call: instantiation_nonce=2,
-call: seal_instantiate=0,
-print: hi!,
-call: seal_debug_message=0,
-call: seal_call=0,
-"##
-    );
+    assert_eq!(&runtime.debug_buffer(), "print: hi!,\n");
 }
 
 #[test]
@@ -888,7 +879,6 @@ fn selector() {
             function f() public pure {}
             function x() public pure {}
         }"##,
-        false,
         true,
     );
 
@@ -1188,6 +1178,7 @@ fn try_catch_transfer_fail() {
             ) {} catch Error(string x) {
                 return hex"41";
             } catch (bytes raw) {
+                print("caught raw exception data");
                 return raw;
             }
 
@@ -1205,13 +1196,11 @@ fn try_catch_transfer_fail() {
         function foo() public pure {}
     }"#,
         true,
-        true,
     );
 
     // Expect the contract to catch the reverting child constructor
     runtime.function("test", 0u128.encode());
     assert_eq!(runtime.output(), vec![0x41u8].encode());
-    assert!(runtime.debug_buffer().contains("seal_instantiate=2"));
 
     // Trying to instantiate with value while having insufficient funds result in
     // seal_instantiate failing with transfer failed (return code 5).
@@ -1219,7 +1208,7 @@ fn try_catch_transfer_fail() {
     // return data to be decoded.
     runtime.function("test", 1u128.encode());
     assert_eq!(runtime.output(), Vec::<u8>::new().encode());
-    assert!(runtime.debug_buffer().contains("seal_instantiate=5"));
+    assert!(runtime.debug_buffer().contains("caught raw exception data"));
 }
 
 #[test]

+ 0 - 6
tests/polkadot_tests/debug_buffer_format.rs

@@ -19,16 +19,13 @@ fn debug_buffer_format() {
         }
     "#,
         true,
-        true,
     );
 
     runtime.function("multiple_prints", [].to_vec());
     assert_eq!(
         runtime.debug_buffer(),
         r#"print: Hello!,
-call: seal_debug_message=0,
 print: I call seal_debug_message under the hood!,
-call: seal_debug_message=0,
 "#
     );
 
@@ -36,11 +33,8 @@ call: seal_debug_message=0,
     assert_eq!(
         runtime.debug_buffer(),
         r#"print: Hello!,
-call: seal_debug_message=0,
 print: I call seal_debug_message under the hood!,
-call: seal_debug_message=0,
 runtime_error: sesa!!! revert encountered in test.sol:10:17-34,
-call: seal_debug_message=0,
 "#
     );
 }

+ 4 - 10
tests/polkadot_tests/expressions.rs

@@ -942,7 +942,7 @@ fn test_power_overflow_boundaries() {
         }"#
         .replace("intN", &format!("int{width}"));
 
-        let mut contract = build_solidity_with_options(&src, false, false);
+        let mut contract = build_solidity_with_options(&src, false);
 
         let base = BigUint::from(2_u32);
         let mut base_data = base.to_bytes_le();
@@ -1123,7 +1123,7 @@ fn test_overflow_boundaries() {
             }
         }"#
         .replace("intN", &format!("int{width}"));
-        let mut contract = build_solidity_with_options(&src, false, false);
+        let mut contract = build_solidity_with_options(&src, false);
 
         // The range of values that can be held in signed N bits is [-2^(N-1), 2^(N-1)-1]. We generate these boundaries:
         let upper_boundary = BigInt::from(2_u32).pow(width - 1).sub(1_u32);
@@ -1248,7 +1248,7 @@ fn test_overflow_detect_signed() {
             }
         }"#
         .replace("intN", &format!("int{width}"));
-        let mut contract = build_solidity_with_options(&src, false, false);
+        let mut contract = build_solidity_with_options(&src, false);
 
         // The range of values that can be held in signed N bits is [-2^(N-1), 2^(N-1)-1] .Generate a value that will overflow this range:
         let limit = BigInt::from(2_u32).pow(width - 1).sub(1_u32);
@@ -1307,7 +1307,7 @@ fn test_overflow_detect_unsigned() {
             }
         }"#
         .replace("intN", &format!("int{width}"));
-        let mut contract = build_solidity_with_options(&src, false, false);
+        let mut contract = build_solidity_with_options(&src, false);
 
         // The range of values that can be held in signed N bits is [-2^(N-1), 2^(N-1)-1].
         let limit = BigUint::from(2_u32).pow(width).sub(1_u32);
@@ -1660,7 +1660,6 @@ fn addition_overflow() {
         }
         "#,
         false,
-        false,
     );
 
     runtime.function_expect_failure("bar", Vec::new());
@@ -1684,7 +1683,6 @@ fn unchecked_addition_overflow() {
         }
         "#,
         false,
-        false,
     );
 
     runtime.function("bar", Vec::new());
@@ -1706,7 +1704,6 @@ fn subtraction_underflow() {
         }
         "#,
         false,
-        false,
     );
 
     runtime.function_expect_failure("bar", Vec::new());
@@ -1730,7 +1727,6 @@ fn unchecked_subtraction_underflow() {
         }
         "#,
         false,
-        false,
     );
 
     runtime.function("bar", Vec::new());
@@ -1752,7 +1748,6 @@ fn multiplication_overflow() {
         }
         "#,
         false,
-        false,
     );
 
     runtime.function_expect_failure("bar", Vec::new());
@@ -1776,7 +1771,6 @@ fn unchecked_multiplication_overflow() {
         }
         "#,
         false,
-        false,
     );
 
     runtime.function("bar", Vec::new());

+ 1 - 1
tests/polkadot_tests/functions.rs

@@ -621,7 +621,7 @@ fn virtual_function_member_access() {
         }"##;
 
     // The create function is the only one appearing in the metadata.
-    let abi = load_abi(&build_wasm(src, false, false)[0].1);
+    let abi = load_abi(&build_wasm(src, false)[0].1);
     let messages = abi.spec().messages();
     assert_eq!(messages.len(), 1);
     assert_eq!(messages[0].label(), "create");

+ 0 - 2
tests/polkadot_tests/inheritance.rs

@@ -37,7 +37,6 @@ fn test_abstract() {
         Target::default_polkadot(),
         &Options {
             opt_level: OptimizationLevel::Default,
-            log_api_return_codes: false,
             log_runtime_errors: false,
             log_prints: true,
             #[cfg(feature = "wasm_opt")]
@@ -84,7 +83,6 @@ fn test_abstract() {
         Target::default_polkadot(),
         &Options {
             opt_level: OptimizationLevel::Default,
-            log_api_return_codes: false,
             log_runtime_errors: false,
             log_prints: true,
             #[cfg(feature = "wasm_opt")]

+ 0 - 1
tests/solana.rs

@@ -172,7 +172,6 @@ impl VirtualMachineBuilder {
             Target::Solana,
             self.opts.as_ref().unwrap_or(&Options {
                 opt_level: OptimizationLevel::Default,
-                log_api_return_codes: false,
                 log_runtime_errors: true,
                 log_prints: true,
                 ..Default::default()

+ 0 - 1
tests/soroban.rs

@@ -27,7 +27,6 @@ pub fn build_solidity(src: &str) -> SorobanEnv {
         target,
         &Options {
             opt_level: opt.into(),
-            log_api_return_codes: false,
             log_runtime_errors: false,
             log_prints: true,
             #[cfg(feature = "wasm_opt")]

+ 0 - 1
tests/undefined_variable_detection.rs

@@ -23,7 +23,6 @@ fn parse_and_codegen(src: &'static str) -> Namespace {
         common_subexpression_elimination: false,
         opt_level: OptimizationLevel::Default,
         generate_debug_information: false,
-        log_api_return_codes: false,
         log_runtime_errors: false,
         log_prints: true,
         #[cfg(feature = "wasm_opt")]