Skip to content

Conversation

@linh2931
Copy link
Contributor

@linh2931 linh2931 commented May 22, 2025

Change Description

  • Generate call and call_results sections in ABI files for sync calls
  • Bump ABI version to 1.3
  • Add test for new call and call_results sections

Please note, this PR removes an earlier feature that allowed a method to be tagged both as an action and a call. The removal prevents two problems:

  1. The ABI definition of a call includes header. If a method is tagged both as an action and a call, it shares the same ABI definition, which includes the header field. That breaks the existing action ABI, and also leads to two different ABI definitions for actions tagged as action only, or tagged as both action and call, Furthermore, when cleos is used to push an action/transaction, the header must be specified, which is not applicable to actions.
  2. If a method is tagged as action in the declaration (in header file) but tagged as call in the implementation, it is treated as tagged as both action and call. This causes confusion. Now a compile error will be reported if a method is tagged inconsistently.

Resolves #344

For the following contract

#include <eosio/call.hpp>
#include <eosio/eosio.hpp>

class [[eosio::contract]] sync_call_test : public eosio::contract {
public:
   using contract::contract;

   [[eosio::call]]
   uint32_t noparam() {
      return 10;
   }

   [[eosio::call]]
   uint32_t withparam(uint32_t in) {
      return in;
   }

   [[eosio::call]]
   void voidfunc() {
      int i = 10;
   }

   [[eosio::call]]
   uint32_t sum(uint32_t a, uint32_t b, uint32_t c) {
      return a + b + c;
   }
};

The ABI file is

{
    "____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
    "version": "eosio::abi/1.3",
    "types": [],
    "structs": [
        {
            "name": "call_data_header",
            "base": "",
            "fields": [
                {
                    "name": "version",
                    "type": "uint32"
                },
                {
                    "name": "func_name",
                    "type": "uint64"
                }
            ]
        },
        {
            "name": "noparam",
            "base": "",
            "fields": [
                {
                    "name": "header",
                    "type": "call_data_header"
                }
            ]
        },
        {
            "name": "sum",
            "base": "",
            "fields": [
                {
                    "name": "header",
                    "type": "call_data_header"
                },
                {
                    "name": "a",
                    "type": "uint32"
                },
                {
                    "name": "b",
                    "type": "uint32"
                },
                {
                    "name": "c",
                    "type": "uint32"
                }
            ]
        },
        {
            "name": "voidfunc",
            "base": "",
            "fields": [
                {
                    "name": "header",
                    "type": "call_data_header"
                }
            ]
        },
        {
            "name": "withparam",
            "base": "",
            "fields": [
                {
                    "name": "header",
                    "type": "call_data_header"
                },
                {
                    "name": "in",
                    "type": "uint32"
                }
            ]
        }
    ],
    "actions": [],
    "tables": [],
    "ricardian_clauses": [],
    "variants": [],
    "action_results": [],
    "calls": [
        {
            "name": "noparam",
            "type": "noparam"
        },
        {
            "name": "sum",
            "type": "sum"
        },
        {
            "name": "voidfunc",
            "type": "voidfunc"
        },
        {
            "name": "withparam",
            "type": "withparam"
        }
    ],
    "call_results": [
        {
            "name": "noparam",
            "result_type": "uint32"
        },
        {
            "name": "sum",
            "result_type": "uint32"
        },
        {
            "name": "withparam",
            "result_type": "uint32"
        }
    ]
}

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

@linh2931 linh2931 requested review from heifner and spoonincode May 22, 2025 15:24
@linh2931 linh2931 linked an issue May 22, 2025 that may be closed by this pull request
/* TODO add some way of defaulting these to the current highest version */
int abi_version_major = 1;
int abi_version_minor = 2;
int abi_version_minor = 3;
Copy link
Contributor

@greg7mdp greg7mdp Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the abi version should be updated to 1.3 only if sync calls are used #355, but probably this should be done in a separate PR.
For now it might be better to leave the version at 1.2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is on sync_call branch only, for now I just keep it as is. When it is merged into main, it will be updated based on how #355 handles versions.

@spoonincode
Copy link
Contributor

LGTM, seems problem with test though

{
"tests" : [
{
"compile_flags": ["--abi-version=1.2"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these are needed anymore, see #360

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change to use the scheme introduced by #360 when merge the main to sync_call branch. For now, I'd like to get this PR into sync_call branch first to minimize changes in the PR.

@linh2931
Copy link
Contributor Author

linh2931 commented Jul 7, 2025

Todo in dev-preview-2: AntelopeIO/spring#1688

Base automatically changed from call_wrapper to sync_call_entry_func July 9, 2025 15:08
Base automatically changed from sync_call_entry_func to sync_call July 9, 2025 20:44
@linh2931 linh2931 merged commit ac6952d into sync_call Jul 9, 2025
7 checks passed
@linh2931 linh2931 deleted the call_abi branch July 9, 2025 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SC: Generate a new ABI section for sync calls

5 participants