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

Hedera Hashgraph #4429

Closed
stefan-stefanooov opened this issue Sep 29, 2023 · 4 comments
Closed

Hedera Hashgraph #4429

stefan-stefanooov opened this issue Sep 29, 2023 · 4 comments
Assignees

Comments

@stefan-stefanooov
Copy link

stefan-stefanooov commented Sep 29, 2023

Version of Hardhat

^2.17.3

What happened?

Hello everyone,

I am working on the Hedera Hashgraph project.
We are trying to integrate with your wonderful project for obvious reasons :)

In Hedera we have a thing called system contracts that allow the network to expose native service implementations on top of the EVM through smart contracts.

They are called from a predefined address. ("0x167" for example)
If we create a smart contract, that uses this address and write a test for it with your tool, we get the following error:
image

A little something from the "--show-stack-traces" flag ...
image

Can you please have a look?
We would really like for you to support our project.

Please let me know if I can do anything else to help US solve this.

Best of wishes,
Stefan

Minimal reproduction steps

  • Create a normal out of the box hardhat project.
    npm install --save-dev hardhat
    npx hardhat init --- use TypeScript
  • add the 4 contracts and test file in the GitHub gist
  • run the tests
  • we also use this tool for our code-caverage

Search terms

hedera hashgraph hardhat precompile address code-coverage

@ChristopherDedominici
Copy link
Contributor

ChristopherDedominici commented Oct 10, 2023

Hi @stefan-stefanooov, I'm checking the issue and I have a question: is the GitHub gist that you shared correct? I see a lot of code that I cannot understand, see screenshot:

image

@ChristopherDedominici ChristopherDedominici added status:needs-more-info There's not enough information to start working on this issue and removed status:triaging labels Oct 10, 2023
@stefan-stefanooov
Copy link
Author

Apologies Sir @ChristopherDedominici ,
I just edited my link ...hopefully to the correct gist.
Please confirm that you can open it. And that it's something meaningful.

I'll also add it here.
https://gist.github.com/stefan-stefanooov/08191e704db60aacda6e6c7d0332969c

Thank you for checking this out :)
I am here for you if you need me for more clarifications.

@fvictorio fvictorio added status:triaging and removed status:needs-more-info There's not enough information to start working on this issue labels Oct 13, 2023
@fvictorio
Copy link
Member

Hey @stefan-stefanooov, I can confirm that your transaction is reverting, but that doesn't necessarily mean there's a bug in Hardhat.

If you think this is happening because the code assumes that some precompile exist, then the problem is that the Hardhat network only has Ethereum's standard precompiles. If you want to simulate those, then you need to have some bytecode in those addresses with the same functionality (you can use hardhat_setCode for that).

I'm tentatively closing this, but I can re-open it if there's indeed a problem on our side.

@fvictorio fvictorio closed this as not planned Won't fix, can't repro, duplicate, stale Oct 20, 2023
@github-project-automation github-project-automation bot moved this from Backlog to Done in Hardhat Oct 20, 2023
@fvictorio
Copy link
Member

I think what's going on here. This code:

        (bool success, bytes memory result) = precompileAddress.call(
            abi.encodeWithSelector(IHederaTokenService.cryptoTransfer.selector, tokenTransfers));
        responseCode = success ? abi.decode(result, (int32)) : HederaResponseCodes.UNKNOWN;

is making a call to an address (0x167) that doesn't have bytecode. But low-level calls (done with address.call) to addresses without bytecode always succeed, with an empty result. You can confirm this by adding some logs:

        (bool success, bytes memory result) = precompileAddress.call(
            abi.encodeWithSelector(IHederaTokenService.cryptoTransfer.selector, tokenTransfers));
        console.log(success);
        console.logBytes(result);
        responseCode = success ? abi.decode(result, (int32)) : HederaResponseCodes.UNKNOWN;

So you are doing abi.decode(result, (int32)) with an empty result, and that fails.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

No branches or pull requests

3 participants