Skip to content

Improve Solidity ABI support in codegen, ink_env and ink_e2e #2517

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

Open
wants to merge 31 commits into
base: master
Choose a base branch
from

Conversation

davidsemakula
Copy link
Collaborator

@davidsemakula davidsemakula commented Jun 2, 2025

Summary

Closes #_

  • [y] y/n | Does it introduce breaking changes?
  • [y] y/n | Is it dependent on a specific version of cargo-contract or pallet-revive?

Description

  • Update trait definitions codegen to properly support Solidity ABI (i.e. generate trait info for Solidity selectors, and update related generated message builders, call builders and call forwarders)
  • Make generated contract references, trait message builders and call forwarders generic over "ink" and "sol" ABI marker types, and update related macros (i.e. ink::contract_ref! and ink::message_builder!) to support ABI parameters
  • More consistent naming of ABI marker types and corresponding generic type parameters (i.e. Abi for the generic type param and enum, and Ink and Sol for the marker types)
  • Refactor Solidity selector computation utilities (prefer compile-time overhead over generating intermediate code)
  • Add Solidity ABI encoding/decoding input and output guards for message and constructors parameter types and message return types (see ink::codegen::DispatchInputSol and ink::codegen::DispatchOutputSol docs)
  • Introduce ink_env::build_call_abi<Environment, Abi>, ink_e2e::call_builder_abi<Contract, Abi> and ink_e2e::InstantiationResult::call_builder_abi<Contract, Abi> utilities
  • Update call results abstractions in ink_e2e to support Solidity ABI encoded message calls (i.e. CallDryRunResult::message_result and CallDryRunResult::return_value)
  • Don't generate ink! metadata generator (i.e. __ink_generate_metadata) for Solidity ABI only contracts
  • Fix SolEncode implementation for ArgumentLists including dynamic types.

Checklist before requesting a review

  • I have added an entry to CHANGELOG.md
  • I have commented on my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

@davidsemakula davidsemakula changed the title Improve Solidity ABI support in codegen and e2e Improve Solidity ABI support in trait definitions codegen and e2e call results abstractions Jun 2, 2025
@davidsemakula davidsemakula force-pushed the semakula/sol-abi branch 2 times, most recently from 8844bb0 to 77fd36b Compare June 5, 2025 12:59
@davidsemakula davidsemakula changed the title Improve Solidity ABI support in trait definitions codegen and e2e call results abstractions Improve Solidity ABI support in codegen, ink_env and ink_e2e Jun 5, 2025
@davidsemakula davidsemakula self-assigned this Jun 5, 2025
@davidsemakula davidsemakula force-pushed the semakula/sol-abi branch 14 times, most recently from 82c595d to ea17ad7 Compare June 12, 2025 09:06
Copy link

github-actions bot commented Jun 12, 2025

🦑 📈 ink! Example Contracts ‒ Changes Report 📉 🦑

These are the results when building the integration-tests/* contracts from this branch with 0 and comparing them to ink! master:

Show Results
Contract Upstream Size (kB) PR Size (kB) Diff (kB) Diff (%) Change
call-builder-return-value 20.783 20.783 0 0
call-runtime 2.194 2.194 0 0
combined-extension 2.51 2.51 0 0
complex-storage-structures 4.296 4.296 0 0
conditional-compilation 1.448 1.448 0 0
contract-invocation 7.936 7.937 0.001 0.0126008 📈
contract-invocation/contract1 1.844 1.844 0 0
contract-invocation/contract2 1.804 1.804 0 0
contract-invocation/virtual_contract 4.222 4.222 0 0
contract-invocation/virtual_contract_ver1 1.852 1.852 0 0
contract-invocation/virtual_contract_ver2 1.864 1.864 0 0
contract-storage 18.448 18.448 0 0
contract-terminate 1.414 1.414 0 0
contract-transfer 3.036 3.036 0 0
contract-xcm 28.207 28.207 0 0
cross-contract-calls 8.774 8.774 0 0
cross-contract-calls/other-contract 1.524 1.524 0 0
custom-allocator 3.012 3.012 0 0
custom-environment 2.23 2.23 0 0
debugging-strategies 4.086 4.086 0 0
dns 8.06 8.06 0 0
e2e-call-runtime 1.673 1.673 0 0
e2e-runtime-only-backend 2.25 2.25 0 0
erc1155 19.194 19.194 0 0
erc20 9.445 9.445 0 0
erc721 11.034 11.034 0 0
events 5.982 5.982 0 0
flipper 1.597 1.597 0 0
incrementer 1.284 1.284 0 0
lang-err/call-builder 8.457 8.457 0 0
lang-err/call-builder-delegate 3.136 3.136 0 0
lang-err/constructors-return-value 2.226 2.226 0 0
lang-err/contract-ref 7.626 7.626 0 0
lang-err/integration-flipper 1.795 1.795 0 0
lazyvec 4.908 4.908 0 0
mapping 9.507 9.507 0 0
mother 13.622 13.622 0 0
multi-contract-caller 12.784 12.784 0 0
multi-contract-caller/accumulator 1.141 1.141 0 0
multi-contract-caller/adder 3.129 3.129 0 0
multi-contract-caller/subber 3.137 3.137 0 0
multisig 24.379 24.379 0 0
own-code-hash 2.204 2.204 0 0
payment-channel 11.015 11.015 0 0
psp22-extension 7.378 7.378 0 0
rand-extension 3.451 3.451 0 0
runtime-call-contract 1.527 1.527 0 0
solidity-abi/events 5.248 9.361 4.113 78.3727 📈
solidity-abi/sol-cross-contract 4.907 6.679 1.772 36.1117 📈
solidity-abi/sol-cross-contract/other-contract-sol 1.634 1.634 0 0
solidity-abi/sol-cross-contract/other-contract-sol 1.634 2.474 0.84 51.4076 📈
solidity-abi/sol-encoding 1.56 2.403 0.843 54.0385 📈
solidity-abi/solidity-calls-flipper 6.253 8.733 2.48 39.661 📈
sr25519-verification 0.957 0.957 0 0
static-buffer 2.502 2.502 0 0
storage-types 15.914 15.914 0 0
trait-dyn-cross-contract-calls 3.579 3.579 0 0
trait-dyn-cross-contract-calls/contracts/incrementer 1.589 1.589 0 0
trait-erc20 9.745 9.745 0 0
trait-flipper 1.449 1.449 0 0
trait-incrementer 1.659 1.659 0 0
upgradeable-contracts/delegator 5.878 5.878 0 0
upgradeable-contracts/delegator/delegatee 2.62 2.62 0 0
upgradeable-contracts/delegator/delegatee2 2.62 2.62 0 0
upgradeable-contracts/set-code-hash 1.503 1.503 0 0
upgradeable-contracts/set-code-hash-migration 1.503 1.503 0 0
upgradeable-contracts/set-code-hash-migration/migration 1.67 1.67 0 0
upgradeable-contracts/set-code-hash-migration/updated-incrementer 1.701 1.701 0 0
upgradeable-contracts/set-code-hash/updated-incrementer 1.463 1.463 0 0
wildcard-selector 2.79 2.79 0 0

Link to the run | Last update: Thu Jun 26 01:56:13 CEST 2025

@davidsemakula davidsemakula force-pushed the semakula/sol-abi branch 2 times, most recently from d67a9a0 to d80d0ba Compare June 12, 2025 11:50
@davidsemakula davidsemakula marked this pull request as ready for review June 12, 2025 12:04
@davidsemakula davidsemakula requested review from evilrobot-01 and removed request for ascjones June 12, 2025 12:05
@davidsemakula davidsemakula moved this from In progress to In review in ink! + `cargo-contract` v6 Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

1 participant