Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracing shows wrong values for event parameters #679

Closed
1 of 2 tasks
leonardoalt opened this issue Feb 5, 2022 · 2 comments
Closed
1 of 2 tasks

Tracing shows wrong values for event parameters #679

leonardoalt opened this issue Feb 5, 2022 · 2 comments
Labels
A-tracing Area: tracing C-forge Command: forge Cmd-forge-test Command: forge test D-average Difficulty: average P-high Priority: high T-bug Type: bug

Comments

@leonardoalt
Copy link

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.1.0 (bea3ddc 2022-02-05T13:11:27.746438742+00:00)

What command(s) is the bug in?

forge test -vvvv

Operating System

Linux

Describe the bug

Write the following test

pragma solidity >=0.8.10;

import "ds-test/test.sol";

contract Test is DSTest {
    event A(uint, uint);

    function setUp() public {}

    function test_event() public {
        uint a = 42;
        uint t = 9723;
        emit A(a, a);
        emit A(a, t);
        emit A(t, a);
        emit A(t, t);
    }
}

Run forge test -vvvv. On my machine I get the output

[PASS] test_event() (gas: 5623)
Traces:

  [5623] Test::test_event()
    ├─ emit A(: 42, : 42)
    ├─ emit A(: 9723, : 9723)
    ├─ emit A(: 42, : 42)
    ├─ emit A(: 9723, : 9723)
    └─ ← ()
@leonardoalt leonardoalt added the T-bug Type: bug label Feb 5, 2022
@brockelmore
Copy link
Member

brockelmore commented Feb 5, 2022

unfortunately this is upstream in ethabi.

RawLog { topics: [0x83f86eb20c894914ecf65cefc94682009cdb5066a609e8428699fa87b19b5c57], data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 251, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42] }

parsed: Log { params: [LogParam { name: "", value: Uint(42) }, LogParam { name: "", value: Uint(42) }] }

using just an ethabi::Event, unnamed parameters in events break log parsing.

Naming them fixes ethabi bug:

RawLog { topics: [0x83f86eb20c894914ecf65cefc94682009cdb5066a609e8428699fa87b19b5c57], data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 251, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42] }

parsed: Log { params: [LogParam { name: "a", value: Uint(9723) }, LogParam { name: "b", value: Uint(42) }] }

edit: there is an open issue upstream: rust-ethereum/ethabi#206

@onbjerg onbjerg added A-tracing Area: tracing Cmd-forge-test Command: forge test D-average Difficulty: average P-high Priority: high C-forge Command: forge labels Feb 5, 2022
@gakonst
Copy link
Member

gakonst commented Feb 9, 2022

Closing as Brock's workaround works and this is tracked in ethabi

@gakonst gakonst closed this as completed Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tracing Area: tracing C-forge Command: forge Cmd-forge-test Command: forge test D-average Difficulty: average P-high Priority: high T-bug Type: bug
Projects
None yet
Development

No branches or pull requests

4 participants