ABI validation misses parameterized types and selector collisions

Open
#609 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
haskell
Domain
compilers

Research direction

Start with src/Solcore/Desugarer/ContractDispatch.hs:457 and the abiTypeOf behavior described in the report. Use the two Solidity reproductions to inspect parameterized ADT ABI generation and selector collision handling before dispatch generation. Done means both cases produce the specified structured rejection or supported output, with no compiler exception, partial ABI, or colliding selectors accepted.

Written by the indexing model from the issue text.

Description

ABI validation misses both unsupported type shapes and selector collisions. These independent cases occur in the frontend with legacy typeclass resolution with ABI output enabled and specialization disabled.

Parameterized ADT metadata

Generating ABI metadata for Box<uint256> reaches an internal exception instead of producing a structured diagnostic.

import * from std;
import * from std.dispatch;
import * from std.Generic;
import * from std.ABIGeneric;
enum Box<t> { Box(t) }
contract Repro {
  function echo(value: Box<uint256>) public returns (Box<uint256>) {
    return value;
  }
}

Actual: The process terminates with an unstructured exception:

sol-core: contractAbiJson: cannot represent type in ABI: ... Box [... uint256 ...]
CallStack (from HasCallStack):
  error, called at src/Solcore/Desugarer/ContractDispatch.hs:457:15

Repro.abi is left empty in this reproduction. abiTypeOf handles nullary source names but falls through to error for the parameterized ADT.

Expected: Either emit a deliberately supported representation or reject the type with a structured diagnostic, without a compiler exception or partial ABI output.

Distinct methods with the same selector

These distinct method signatures share the same four-byte selector, but the frontend accepts both methods.

import * from std;
import * from std.dispatch;
contract Repro {
  function collision_8764(x: uint256) public returns (uint256) {
    return x;
  }
  function collision_99992(x: uint256) public returns (uint256) {
    return x;
  }
}

Actual: The frontend exits successfully and emits both methods in Repro.abi, although both signatures have selector 0xd443241f.

Expected: Reject distinct external signatures that share a selector before generating dispatch. This report concerns distinct method names; duplicate method names are already rejected by name resolution.

Dominant language
Haskell
Stars
115
Forks
11
Avg merge
20h 29m
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from argotorg/solcore

All issues in argotorg/solcore

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.