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

Return value is 0x double-padded in custom errors. #5793

Closed
vittominacori opened this issue Sep 30, 2024 · 3 comments · Fixed by NomicFoundation/edr#688
Closed

Return value is 0x double-padded in custom errors. #5793

vittominacori opened this issue Sep 30, 2024 · 3 comments · Fixed by NomicFoundation/edr#688
Assignees

Comments

@vittominacori
Copy link
Contributor

Version of Hardhat

2.22.12

What happened?

Hardhat returns 0x padded (twice) values in custom errors.

Note that it works with hardhat@2.22.11.

Minimal reproduction steps

Having that sample contract:

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.27;

contract SampleContract {
    error TestError(address account);

    constructor(address owner) {
        revert TestError(owner);
    }
}

and running the following test:

import hre from 'hardhat';

describe('SampleContract', function () {
  describe('Deployment', function () {
    it('Should fail', async function () {
      const [owner] = await hre.ethers.getSigners();
      const SampleContract = await hre.ethers.getContractFactory('SampleContract');
      await SampleContract.deploy(owner);
    });
  });
});

I receive the following error where the address is 0x padded twice.

Error: VM Exception while processing transaction: reverted with custom error 'TestError("0x0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266")'

Search terms

No response

@Xanewok
Copy link
Contributor

Xanewok commented Sep 30, 2024

Hey @vittominacori, thanks a lot for the report!

This was a small mistake that we did when porting the tracing logic into our Ethereum Development Runtime (EDR) that we enabled by default in the latest release.

I managed to reproduce the issue and can confirm that the fix in NomicFoundation/edr#688 fixes the problem, so this should be fixed once we release a Hardhat version that uses the newest EDR that contains the fix.

cc @fvictorio

@vittominacori
Copy link
Contributor Author

@Xanewok yes, i figured that.
I saw that thelinkHexStringBytecode function was removed and imported from EDR.
Thanks, waiting for the next release.

@kanej
Copy link
Member

kanej commented Oct 10, 2024

The EDR fix was released in Hardhat as part of v2.22.13:

https://github.com/NomicFoundation/hardhat/releases/tag/hardhat%402.22.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants