ABI: `()` is an empty tuple to the codec and SolCompat, but the JSON ABI rejects it
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- rust, solidity
- Domain
- backend-api-design, blockchain, compilers
Research direction
Start in crates/hir/src/analysis/ty/abi_ty.rs at semantic_ty_to_abi_desc and reproduce the discrepancy with the provided fe check and fe build example. Compare the unit handling with the codec, SolCompat for (), and empty #[abi] structs; done means one consistent, decided policy is reflected in JSON ABI generation and the repro behaves accordingly.
Written by the indexing model from the issue text.
Description
Fe disagrees with itself about whether () is an external ABI type.
- The core codec treats
()as an empty tuple:HEAD_SIZE = 0, nothing is encoded. - Since #1606,
impl SolCompat for ()spells it"()", so an#[abi]struct with a()field can be an#[event]or#[error]field. - JSON ABI generation rejects
TyId::unitat every level (semantic_ty_to_abi_descincrates/hir/src/analysis/ty/abi_ty.rs: "unit type is not a valid external ABI parameter"). The check dates from the first JSON ABI implementation, before()could appear nested. - An empty
#[abi]struct is the same ABI type and is accepted:SolCompatgives"()", and the JSON ABI emits{"type": "tuple", "components": []}, even as a function input.
Repro: fe check passes, fe build fails with Failed to generate ABI for C: unit type is not a valid external ABI parameter.
use std::abi::sol
use std::evm::Log
#[abi]
pub struct WithUnit {
pub value: u256,
pub unit: (),
}
#[event]
struct Emitted {
w: WithUnit,
}
msg M {
#[selector = sol("f(uint256)")]
F { value: u256 } -> u256,
}
pub contract C {
recv M {
F { value } -> u256 uses (log: mut Log) {
log.emit(Emitted { w: WithUnit { value, unit: () } })
value
}
}
}
Options:
- Map
()to an empty tuple in the JSON ABI and drop the blanket rejection. This matches empty#[abi]structs, the codec and the ABI spec, which allows tuples of n >= 0 types. - Remove
impl SolCompat for ().()is then not an external ABI type, and an event or error containing it is rejected at the field. - Reject both
()and empty#[abi]structs as external ABI types, as Solidity does, since it disallows empty structs.
Interop caveat for options 1 and 2: Solidity cannot declare an empty tuple or struct, and alloy computes the selector of f(()) but cast abi-encode rejects () values. Empty #[abi] structs already have this caveat.
Found in the review of #1606: https://github.com/argotorg/fe/pull/1606#discussion_r4148997625
- Dominant language
- Rust
- Stars
- 1.7k
- Forks
- 219
- Avg merge
- 1d 3m
- Merged PRs (30d)
- 162
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from argotorg/fe
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 32/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 57/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
Maintainers usually reply within 1 day
Similar issues
-
priority: medium ready
Difficulty 1/5 Under an hour Newbie friendliness 88/100
TusanHomichi/PSIV#646 ·
Maintainers usually reply within 1 day
-
bug lab rust-mcp
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
area:cli good first issue help wanted needs translation priority:P2 type:documentation
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
SpecterAoD/pqkeep#226 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
haowjy/mars-agents#381 ·
Maintainers usually reply within 1 day
-
[Bug]: opencode_go chat route drops reasoning_effort (even 'none'), while the same endpoint honors it via custom_llm_provider=openaiPossibly taken @arvindkumar-ship-it claimed this today. Openllm translation
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
BerriAI/litellm#51871 · 1 comment ·
Maintainers usually reply within 1 day