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

Tuple/Struct support #73 #79

Merged
merged 38 commits into from
Jan 3, 2024
Merged

Tuple/Struct support #73 #79

merged 38 commits into from
Jan 3, 2024

Conversation

jcarraror
Copy link
Contributor

@jcarraror jcarraror commented Sep 10, 2023

TODOs:

  • Check Tuple encoding correctness
  • ABI Json support for tuples
  • Decide how the reflection interface will use the new Decoder
  • Tuple/Struct encoding support
  • Tuple/Struct decoding support
  • ABI Refactor to stop using variant as data collector

@jcarraror jcarraror changed the base branch from main to development September 10, 2023 15:59
src/contract/abi.h Outdated Show resolved Hide resolved
src/contract/contractmanager.h Show resolved Hide resolved
Copy link
Contributor

@itamarcps itamarcps left a comment

Choose a reason for hiding this comment

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

Adding tuple support required us to shift both the ABI and ContractReflectionInterface entirely to a pure template-based approach. This effort, particularly integrating nested tuple/struct support, was more challenging and time-consuming than anticipated, necessitating a complete overhaul of the existing system.

Highlights:

  • The compiler now autonomously generates functions for encoding/decoding types, applicable for each function call, supporting all basic Solidity types.
  • Elimination of dependency on the "meta" metaprogramming library.
  • Capability to return nested tuples and vectors, with compiler-generated code for these structures.

Implementation Example:
See SimpleContract.cpp for examples of the new ABI's application, demonstrating the enhanced handling of std::vector<T>P and std::tuple<T...>.

Impact:
The refactor has affected all areas interacting with the ABI, particularly in DynamicContracts function registrations and JSON ABI generation. New tests have been added to ensure the integrity of these changes.

Notable Changes:

  • Deprecated ABI::Encode::encodeFunction; transition to ABI::FunctorEncode.
  • Removed ABI::Types, BaseTypes, and BytesEncoded as the templated ABI negates their necessity.
  • DynamicContract no longer uses std::any, reflecting the new templated methodology.
  • Removed specializations for decoding/encoding std::vector<BaseSolidityType> since the templated functions handles std::vector<T>.

Next Steps:

  • Remove std::any usage within the ContractFactory.

@itamarcps itamarcps marked this pull request as ready for review January 3, 2024 16:12
@itamarcps itamarcps merged commit c9c6d36 into development Jan 3, 2024
4 checks passed
@itamarcps itamarcps deleted the abi_refactor branch January 3, 2024 16:20
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.

3 participants