Skip to content

Fix Address20 debug format.#4453

Merged
afck merged 3 commits intolinera-io:mainfrom
afck:hex-debug-address-20
Sep 1, 2025
Merged

Fix Address20 debug format.#4453
afck merged 3 commits intolinera-io:mainfrom
afck:hex-debug-address-20

Conversation

@afck
Copy link
Contributor

@afck afck commented Sep 1, 2025

Motivation

AccountOwner::Address20's Debug impl prints something like:

Address20([10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10])

because the hex_debug attribute is in the wrong place.

Proposal

Put the attribute directly on the field, not the enum variant. The Debug impl now says:

Address20(0a0a0a0a0a0a0a0a..)

Test Plan

Tried it locally.

Release Plan

  • Should be backported to testnet and devnet.

Links

/// 20-byte account EVM-compatible address.
#[debug(with = "hex_debug")]
Address20([u8; 20]),
Address20(#[debug(with = "hex_debug")] [u8; 20]),
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add a test for Address20 as well as Address32 (which I assume is correct right now, just unsure because of a lack of test).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! Turns out:

  • For Address32 we only print 8 bytes because of the Debug impl for CryptoHash. I guess I should change that, too, and print the whole hash.
  • For Reserved, we print it in decimal. I guess that's okay, although I'd prefer hexadecimal there, too.

Copy link
Contributor

Choose a reason for hiding this comment

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

For Reserved, we currently have only 0 as a possibility.
This corresponds to CHAIN, so I guess that we can do something here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in c0f8469; but now I'm a bit worried that this will make other log lines more spammy, because now all hashes are four times as long.

(I'll leave changing the representation of Reserved(0) for a later PR; not sure about that.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed, let's print only 8 bytes for both variants instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in e0abfd0.

@afck afck enabled auto-merge September 1, 2025 14:59
@afck afck added this pull request to the merge queue Sep 1, 2025
Merged via the queue into linera-io:main with commit 1dbb107 Sep 1, 2025
28 checks passed
@afck afck deleted the hex-debug-address-20 branch September 1, 2025 15:40
afck added a commit to afck/linera-protocol that referenced this pull request Sep 4, 2025
## Motivation

`AccountOwner::Address20`'s `Debug` impl prints something like:

```
Address20([10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10])
```

because the `hex_debug` attribute is in the wrong place.

## Proposal

Put the attribute directly on the field, not the enum variant. The
`Debug` impl now says:

```
Address20(0a0a0a0a0a0a0a0a..)
```

## Test Plan

Tried it locally.

## Release Plan

- Should be backported to testnet and devnet.

## Links

- [reviewer
checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
@afck afck mentioned this pull request Sep 4, 2025
ma2bd pushed a commit that referenced this pull request Sep 5, 2025
## Motivation

`AccountOwner::Address20`'s `Debug` impl prints something like:

```
Address20([10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10])
```

because the `hex_debug` attribute is in the wrong place.

## Proposal

Put the attribute directly on the field, not the enum variant. The
`Debug` impl now says:

```
Address20(0a0a0a0a0a0a0a0a..)
```

## Test Plan

Tried it locally.

## Release Plan

- Should be backported to testnet and devnet.

## Links

- [reviewer
checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
ma2bd pushed a commit that referenced this pull request Sep 5, 2025
## Motivation

`AccountOwner::Address20`'s `Debug` impl prints something like:

```
Address20([10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10])
```

because the `hex_debug` attribute is in the wrong place.

## Proposal

Put the attribute directly on the field, not the enum variant. The
`Debug` impl now says:

```
Address20(0a0a0a0a0a0a0a0a..)
```

## Test Plan

Tried it locally.

## Release Plan

- Should be backported to testnet and devnet.

## Links

- [reviewer
checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants