Skip to content

Conversation

@m-Peter
Copy link
Collaborator

@m-Peter m-Peter commented Jan 29, 2026

Closes: #8370
Related: onflow/FlowYieldVaultsEVM#40

Summary by CodeRabbit

  • New Features

    • Added support for encoding and decoding Cadence structs as EVM-compatible tuples in ABI operations, enabling proper roundtrip conversion for struct arrays.
  • Tests

    • Added test coverage for struct array encoding and decoding via ABI operations.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

The changes implement ABI encoding and decoding support for arrays of Solidity tuples. A context parameter was added to the type resolution function, tuple-encodable composite detection logic was introduced, and array element handling was updated to properly encode/decode struct arrays as tuple sequences.

Changes

Cohort / File(s) Summary
ABI Encoding Implementation
fvm/evm/impl/abi.go
Updated goType function signature to accept context parameter; added logic to detect and handle tuple-encodable Cadence composites; modified array encoding to pass context and conditionally indirect tuple elements from pointers.
Test Coverage
fvm/evm/stdlib/contract_test.go
Added two test cases validating roundtrip ABI encoding/decoding of arrays containing structs mapped to Solidity tuples; tests verify element values are preserved through encode/decode cycles.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Input: Cadence Array
    participant Encoder as ABI Encoder
    participant TypeResolver as Type Resolver (goType)
    participant ElementHandler as Element Processor
    participant Output as Output: EVM Bytes

    Client->>Encoder: encodeABI([struct1, struct2, ...])
    Encoder->>TypeResolver: goType(context, arrayType)
    TypeResolver->>TypeResolver: Detect tuple-encodable composite
    TypeResolver-->>Encoder: Return array of tuple type
    
    Encoder->>ElementHandler: For each struct element
    ElementHandler->>ElementHandler: Check isTuple flag
    ElementHandler->>ElementHandler: Indirect from pointer if needed
    ElementHandler-->>Encoder: Processed element
    
    Encoder->>Output: Encode to EVM tuple format
    Output-->>Client: Return encoded ABI bytes
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • janezpodhostnik
  • holyfuchs
  • zhangchiqing
  • fxamacker

Poem

🐰 A hop and a skip through struct arrays we go,
Tuples take shape as the encodings flow,
Context-aware paths where the types align,
Cadence and Solidity now intertwine! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: implementing ABI encoding/decoding for arrays of Solidity tuples, which is the primary objective of the PR.
Linked Issues check ✅ Passed The PR implementation matches the linked issue #8370 requirement to add ABI encoding/decoding support for arrays of Solidity tuples, with corresponding test coverage.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing tuple array encoding/decoding: updated goType function signature, added tuple detection logic, adjusted element handling, and added comprehensive test cases.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mpeter/abi-encode-tuple-arrays

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 29, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@codecov-commenter
Copy link

codecov-commenter commented Jan 29, 2026

Codecov Report

❌ Patch coverage is 0% with 21 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
fvm/evm/impl/abi.go 0.00% 21 Missing ⚠️

📢 Thoughts on this report? Let us know!

@m-Peter m-Peter force-pushed the mpeter/abi-encode-tuple-arrays branch from 8dd3fb0 to 9846bf6 Compare January 30, 2026 10:18
@m-Peter m-Peter marked this pull request as ready for review January 30, 2026 10:19
@m-Peter m-Peter requested a review from a team as a code owner January 30, 2026 10:19
// - `EVM.EVMBytes4`
// - `EVM.EVMBytes32`
semaType := interpreter.MustConvertStaticToSemaType(staticType, context)
if compositeType := asTupleEncodableCompositeType(semaType); compositeType != nil {
Copy link
Member

Choose a reason for hiding this comment

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

In the case where compositeType != nil , we are not making use of the compositeType, instead, we are reading from the staticType and context all over again.

I feel we might be able to get rid of this check, just rely on gethABIType to return ok, and check if ok == true, for when the type is a tuple. In other words, if compositeType != nil, then ok must be true, and if it's false, then it should be a fatal error, no?

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Flow EVM] Implement ABI encoding/decoding for arrays of Solidity tuples

4 participants