Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 162 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,167 @@ The sections do not signal obligations; the prefixes do.

## Unreleased

### Added

- The **ethdebug/format/type/elementary/flags** type is new. It is a set of
named members, with `values` (a list of unique strings) and an optional
`definition`. A set bit `i` in the value's bytes means `values[i]` is
present. Zero is the empty set. A set bit at or past the length of `values`
is invalid ([#282]).
- Schemas: **ethdebug/format/type/elementary/flags**
- Producers: optional: a type may have kind `flags`.
- Consumers: required: a type may have kind `flags`. A consumer must read it
as described to read the data at all.

- The **ethdebug/format/type/complex/variant** type is new. It has `cases`,
a list of `name`, `discriminant` (an **ethdebug/format/data/value**) and
optional `payload` (a type wrapper), and an optional `definition`. The type
says what each case is. The active case is the one whose `discriminant`
matches the value read as the discriminant. No match is invalid ([#282]).
- Schemas: **ethdebug/format/type/complex/variant**
- Producers: optional: a type may have kind `variant`.
- Consumers: required: a type may have kind `variant`. A consumer must read
it as described to read the data at all.

### Changed

- Every type kind is replaced. A type now says what a value is, and no longer
says where its bytes are or how many there are. The layout keywords `bits`,
`size` and `count` are gone, and the integer, fixed-point, address and
tuple kinds merge into fewer kinds. The descriptions of most kinds now
state their standard interpretation: how a consumer reads a value from the
bytes the value occupies. Every type may have an optional `label`, the type
as its language spells it (e.g., `uint256`, `bytes32`, `uint8[3]`), for
display only. Nothing interprets a label. A complex base type may now omit
`contains` if it gives `class` as `complex`, since the new `variant` and
`function` kinds have no `contains` ([#282]).
- Schemas: **ethdebug/format/type**, **ethdebug/format/type/base**,
**ethdebug/format/type/elementary**, **ethdebug/format/type/complex**,
**ethdebug/format/type/specifier**
- Producers: required: the kinds below replace the old kinds, and the old
kinds no longer validate. See the entries for each kind.
- Consumers: required: producers emit the new kinds. A consumer must read
them and must not expect the old kinds. See the entries for each kind.
A consumer that uses **ethdebug/format/type/base** to classify complex
types must accept a complex type without `contains`.

- The **ethdebug/format/type/elementary/number** type replaces the `uint`,
`int`, `ufixed` and `fixed` kinds. It has an optional `signed` (default
false) and an optional `places` (default 0, minimum 0), and has no width.
The value is the big-endian integer over the value's bytes, in two's
complement if `signed`, divided by 10 to the power of `places`. For
example, `{ "kind": "uint", "bits": 256 }` becomes
`{ "kind": "number", "label": "uint256" }`, and
`{ "kind": "int", "bits": 8 }` becomes
`{ "kind": "number", "signed": true, "label": "int8" }` ([#282]).
- Schemas: **ethdebug/format/type/elementary/number**,
**ethdebug/format/type/elementary/uint**,
**ethdebug/format/type/elementary/int**,
**ethdebug/format/type/elementary/ufixed**,
**ethdebug/format/type/elementary/fixed**
- Producers: required: the schemas for kinds `uint`, `int`, `ufixed` and
`fixed` are removed, so a type with one of those kinds no longer
validates. Use kind `number`. The `bits` keyword has no meaning now, and
consumers ignore it.
- Consumers: required: a type with kind `number` is an integer or fixed-point
number as described. The width comes from the pointer, not the type.

- The **ethdebug/format/type/elementary/address** type now also covers
contract references, and the `contract` kind is removed. An address has an
optional `payable` (absent means unknown) and an optional `definition`. A
type without `definition` is a plain address. A type with `definition` is a
reference to a contract, and the `definition` may also have `library` or
`interface` (not both true) ([#282]).
- Schemas: **ethdebug/format/type/elementary/address**,
**ethdebug/format/type/elementary/contract**
- Producers: required: the schema for kind `contract` is removed. Use kind
`address` with a `definition`.
- Consumers: required: a type with kind `address` and a `definition`
refers to a contract. It is read as an address.

- The **ethdebug/format/type/elementary/bytes** type no longer has `size`.
Its value is the bytes of the value, in order ([#282]).
- Schemas: **ethdebug/format/type/elementary/bytes**
- Producers: required: the `size` keyword is removed. It has no meaning now,
and consumers ignore it. A fixed-size `bytes` type is
`{ "kind": "bytes" }`, and the pointer gives the size.
- Consumers: required: a type with kind `bytes` has no `size`. Take the
length from the bytes the value occupies.

- The **ethdebug/format/type/elementary/enum** type now has `values` as a
non-empty list of unique strings. The value is the unsigned big-endian
integer `i` over the value's bytes, and the member is `values[i]`. An `i`
past the end of `values` is invalid ([#282]).
- Schemas: **ethdebug/format/type/elementary/enum**
- Producers: required: `values` must be a non-empty list of unique
strings. Data with any other `values` no longer validates.
- Consumers: required: read an enum value as the index into `values`
described above.

- The **ethdebug/format/type/elementary/bool** and
**ethdebug/format/type/elementary/string** types may have a `label`, and
their descriptions now state the standard interpretation. A bool is 0
(false) or 1 (true). A string is text in its `encoding` (default utf-8)
([#282]).
- Schemas: **ethdebug/format/type/elementary/bool**,
**ethdebug/format/type/elementary/string**
- Producers: optional: a type may have a `label`.
- Consumers: required: "Any other value is invalid" (bool) and "If the
bytes are not a valid sequence in that encoding, the value is invalid"
(string). The previous text did not say how to read such values.

- The **ethdebug/format/type/complex/struct** type replaces the `tuple`
kind. A struct has an ordered `contains` list whose items may each have a
`name`. An unnamed list is a tuple, and the list may be empty. The
`definition` is optional ([#282]).
- Schemas: **ethdebug/format/type/complex/struct**,
**ethdebug/format/type/complex/tuple**
- Producers: required: the schema for kind `tuple` is removed. Use kind
`struct` with unnamed items.
- Consumers: required: a type with kind `struct` may have unnamed items,
and may have none.

- The **ethdebug/format/type/complex/array** type no longer has `count`. Its
items are all of the `contains` type. The pointer gives how many there are
([#282]).
- Schemas: **ethdebug/format/type/complex/array**
- Producers: required: the `count` keyword is removed. It has no meaning
now, and consumers ignore it. A stale `count` does not fix the length of
the array.
- Consumers: required: an array type has no length. Take the item count
from the pointer.

- The **ethdebug/format/type/complex/function** type has a new shape.
`parameters` and `returns` are top-level lists (`returns` is required, and
`[]` means no values). They replace `contains.parameters` and
`contains.returns`. An external function may have a top-level `contract`
wrapper, whose type is an **ethdebug/format/type/elementary/address**
with a `definition` or a type reference. It replaces `contains.contract`.
Exactly one of `internal` and `external` is true, as before ([#282]).
- Schemas: **ethdebug/format/type/complex/function**
- Producers: required: `returns` is required, so data in the old shape no
longer validates. `contains` has no meaning in a function type now, and
consumers ignore it.
- Consumers: required: read `parameters`, `returns` and `contract` at the
top level of the function type.

- The **ethdebug/format/type/complex/alias** and
**ethdebug/format/type/complex/mapping** types may have a `label`, and
their descriptions now state the standard interpretation. An alias is read
as its `contains` type. A mapping entry's value is read as the `value` type
and its key as the `key` type ([#282]).
- Schemas: **ethdebug/format/type/complex/alias**,
**ethdebug/format/type/complex/mapping**
- Producers: optional: a type may have a `label`.
- Consumers: no change needed. The new prose describes how these kinds
were already read.

- The examples that embed types now use the new kinds ([#282]).
- Schemas: **ethdebug/format/info**, **ethdebug/format/info/resources**,
**ethdebug/format/program**
- Producers: no change needed.
- Consumers: no change needed.

## 0.1.0-draft.3 — 2026-11-19

### Added
Expand Down Expand Up @@ -793,6 +954,7 @@ First published version of the specification.
[#279]: https://github.com/ethdebug/format/pull/279
[#280]: https://github.com/ethdebug/format/pull/280
[#281]: https://github.com/ethdebug/format/pull/281
[#282]: https://github.com/ethdebug/format/issues/282
[#284]: https://github.com/ethdebug/format/pull/284
[#285]: https://github.com/ethdebug/format/pull/285
[#286]: https://github.com/ethdebug/format/pull/286
Expand Down
17 changes: 17 additions & 0 deletions packages/bugc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ support. Changes to the specification itself are tracked in the root

## Unreleased

### Changed

- The debug information's types use the new type kinds. An integer type is
`{ "kind": "number", "label": "uint256" }`, and a signed one adds
`"signed": true`. `bytes` and `bytesN` are `{ "kind": "bytes" }`, with the
spelling in `label` and no `size`. An array has no `count`. `address`,
`bool` and `string` types carry a `label`. A scalar that comes from the
compiler and not from a source type is `{ "kind": "number" }` or
`{ "kind": "address" }` and has no label. The emitted code is the same
([#282]).

### Fixed

- An array type's element count was emitted as `length`, which the schema
does not define. It is no longer emitted ([#282]).

## 0.1.0-preview.3 — 2026-11-19

### Added
Expand Down Expand Up @@ -574,6 +590,7 @@ The version scheme changed: prerelease versions are now `preview.<n>`, and

First publication.

[#282]: https://github.com/ethdebug/format/issues/282
[#286]: https://github.com/ethdebug/format/pull/286
[#298]: https://github.com/ethdebug/format/pull/298
[#300]: https://github.com/ethdebug/format/pull/300
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1656,10 +1656,10 @@ code {
const strings = await pointerOf("string calldata");
const bytes = await pointerOf("bytes calldata");
for (const entry of strings) {
expect(entry.type).toEqual({ kind: "string" });
expect(entry.type).toEqual({ kind: "string", label: "string" });
}
for (const entry of bytes) {
expect(entry.type).toEqual({ kind: "bytes" });
expect(entry.type).toEqual({ kind: "bytes", label: "bytes" });
}
expect(strings.map((entry) => entry.pointer)).toEqual(
bytes.map((entry) => entry.pointer),
Expand Down
2 changes: 1 addition & 1 deletion packages/bugc/src/evmgen/debug/local-variables.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ code { r = add(3, 4); }`;
expect(entry, `variables entry for ${name}`).toBeDefined();
expect(entry!.identifier).toBe(name);
expect(isFrameRelative(entry!.pointer)).toBe(true);
expect(entry!.type).toEqual({ kind: "uint", bits: 256 });
expect(entry!.type).toEqual({ kind: "number", label: "uint256" });
}
});

Expand Down
22 changes: 22 additions & 0 deletions packages/bugc/src/irgen/debug/types.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { describe, it, expect } from "vitest";

import { Type as BugType } from "#types";

import { convertBugType } from "./types.js";

describe("convertBugType", () => {
it("emits an unsigned number for uint", () => {
expect(convertBugType(BugType.Elementary.uint(256))).toEqual({
kind: "number",
label: "uint256",
});
});

it("emits a signed number for int", () => {
expect(convertBugType(BugType.Elementary.int(8))).toEqual({
kind: "number",
signed: true,
label: "int8",
});
});
});
63 changes: 15 additions & 48 deletions packages/bugc/src/irgen/debug/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export function convertBugType(bugType: BugType): Format.Type | undefined {
contains: {
type: elementType,
},
...(bugType.size !== undefined && { length: bugType.size }),
};
}

Expand Down Expand Up @@ -113,47 +112,30 @@ function convertElementaryType(

switch (kind) {
case "uint":
return {
kind: "uint",
bits: elementary.bits,
};
return { kind: "number", label: `uint${elementary.bits}` };

case "int":
return {
kind: "int",
bits: elementary.bits,
kind: "number",
signed: true,
label: `int${elementary.bits}`,
};

case "address":
return {
kind: "address",
// payable is optional, omit if unknown
};
return { kind: "address", label: "address" };

case "bool":
return { kind: "bool", label: "bool" };

case "bytes":
return {
kind: "bool",
kind: "bytes",
label:
elementary.size !== undefined ? `bytes${elementary.size}` : "bytes",
};

case "bytes": {
if (elementary.size !== undefined) {
// Fixed-size bytes (bytes1 - bytes32)
return {
kind: "bytes",
size: elementary.size,
};
} else {
// Dynamic bytes
return {
kind: "bytes",
};
}
}

case "string":
return {
kind: "string",
};
return { kind: "string", label: "string" };

default:
return undefined;
Expand All @@ -168,28 +150,13 @@ function convertElementaryType(
*/
function convertSyntheticType(irType: Ir.Type): Format.Type | undefined {
if (Ir.Type.isScalar(irType)) {
// Scalar types - infer based on size
const bits = irType.size * 8;

// Common patterns for synthetic scalars
if (irType.size === 32) {
// Most 32-byte scalars are uint256
return { kind: "uint", bits: 256 };
}

// Scalar types - infer based on size; bugc knows no spelling,
// so synthetic types carry no label
if (irType.size === 20) {
// 20-byte scalars are addresses
return { kind: "address" };
}

if (irType.size === 1) {
// 1-byte scalars could be bool or uint8
// Default to uint8 for safety
return { kind: "uint", bits: 8 };
}

// For other sizes, use uint with appropriate bit size
return { kind: "uint", bits };
return { kind: "number" };
}

if (Ir.Type.isRef(irType)) {
Expand Down
Loading
Loading