Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read-only transaction reporting #1120

Merged
merged 2 commits into from
Jan 25, 2025
Merged

Read-only transaction reporting #1120

merged 2 commits into from
Jan 25, 2025

Conversation

heifner
Copy link
Member

@heifner heifner commented Jan 24, 2025

  • Report cpu_usage_us and net_usage_words as 0 in read-only transaction trace receipt.
    • Rational: read-only transactions are only executed locally on an API node. They have no on-chain billable CPU or billable NET. Could argue that there should be no receipt for read-only transactions. However, it is likely that existing tooling is expecting receipt for transactions that do not fail.
  • Modify cleos to report elapsed instead of cpu and net for read-only transactions.
  • Remove cleos warning: transaction executed locally, but may not be confirmed by the network yet for read-only and dry-run transactions.
  • Note this PR does keep the net_usage in the receipt for read-only transactions. Since this is not in the receipt, I thought it might be useful for a user to know what the calculated net would be if the transaction was not read-only.

Examples:

./cleos --url http://localhost:8890 --wallet-url http://localhost:9899 --no-auto-keosd push action payloadless doit '{}' --read
executed transaction: af59a47ce5e00c0a778f88707f95969d4a90f044beecd2e18eef49ec2a042fd1   elapsed 192 us
#   payloadless <= payloadless::doit            ""
>> Im a payloadless action
./cleos --url http://localhost:8890 --wallet-url http://localhost:9899 --no-auto-keosd push action payloadless doit '{}' --read -j
{
  "transaction_id": "9b801e162ada0c416ebcc682d8855b4dfca9a7b8a99a392efa4e41929667ef98",
  "processed": {
    "id": "9b801e162ada0c416ebcc682d8855b4dfca9a7b8a99a392efa4e41929667ef98",
    "block_num": 435,
    "block_time": "2025-01-24T15:51:12.500",
    "producer_block_id": null,
    "receipt": {
      "status": "executed",
      "cpu_usage_us": 0,
      "net_usage_words": 0
    },
    "elapsed": 180,
    "net_usage": 64,
    "scheduled": false,
    "action_traces": [{
        "action_ordinal": 1,
        "creator_action_ordinal": 0,
        "closest_unnotified_ancestor_action_ordinal": 0,
        "receipt": {
          "receiver": "payloadless",
          "act_digest": "4f09a630d4456585ee4ec5ef96c14151587367ad381f9da445b6b6239aae82cf",
          "global_sequence": 0,
          "recv_sequence": 0,
          "auth_sequence": [],
          "code_sequence": 1,
          "abi_sequence": 1
        },
        "receiver": "payloadless",
        "act": {
          "account": "payloadless",
          "name": "doit",
          "authorization": [],
          "data": "",
          "hex_data": ""
        },
        "context_free": false,
        "elapsed": 75,
        "console": "Im a payloadless action",
        "trx_id": "9b801e162ada0c416ebcc682d8855b4dfca9a7b8a99a392efa4e41929667ef98",
        "block_num": 435,
        "block_time": "2025-01-24T15:51:12.500",
        "producer_block_id": null,
        "account_ram_deltas": [],
        "except": null,
        "error_code": null,
        "return_value_hex_data": ""
      }
    ],
    "account_ram_delta": null,
    "except": null,
    "error_code": null
  }

Resolves #1085

…nly trxs. Add elapsed for read-only trxs. Also remove warning of not confirmed for read-only and dry-run trxs.
@heifner heifner added the OCI Work exclusive to OCI team label Jan 24, 2025
@heifner heifner requested review from spoonincode and arhag January 24, 2025 18:09
@ericpassmore
Copy link
Contributor

Note:start
category: Other
component: Internal
summary: More accurate read-only transaction reporting. Read-only transactions are only executed locally on an API node. They have no on-chain billable CPU or billable NET.
Note:end

@heifner heifner merged commit b9c9df8 into main Jan 25, 2025
71 checks passed
@heifner heifner deleted the GH-1085-cleos-rotrx branch January 25, 2025 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI Work exclusive to OCI team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

some minor tweaks to cleos output & read only actions
4 participants