huff-language/foundry-huff

Cannot deploy huff smart contract with forge script

Opened this issue · 2 comments

Deploying a huff contract through forge script fails with the following trace:

Traces:
  [2245499] → new Deploy@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496
    └─ ← 11154 bytes of code

  [2160044] Deploy::run()
    ├─ [2059491] → new HuffConfig@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f
    │   └─ ← 10226 bytes of code
    ├─ [679] HuffConfig::set_broadcast(true)
    │   └─ ← HuffConfig: [0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f]
    ├─ [64438] HuffConfig::deploy("flash")
    │   ├─ [0] VM::ffi(["./lib/foundry-huff/scripts/binary_check.sh"])
    │   │   └─ ← 0x01
    │   ├─ [0] VM::ffi(["./lib/foundry-huff/scripts/rand_bytes.sh"])
    │   │   └─ ← 0x79abd4fd40a5bb6ab0bf97e207a83bed
    │   ├─ [0] VM::ffi(["./lib/foundry-huff/scripts/file_writer.sh", "src/__TEMP__ihadllzrxbsnbidjjbjjfcpykjhdyjjaflash.huff", "\n"])
    │   │   └─ ← 0x
    │   ├─ [0] VM::ffi(["./lib/foundry-huff/scripts/read_and_append.sh", "src/__TEMP__ihadllzrxbsnbidjjbjjfcpykjhdyjjaflash.huff", "src/flash.huff"])
    │   │   └─ ← 0x
    │   ├─ [0] VM::ffi(["huffc", "src/__TEMP__ihadllzrxbsnbidjjbjjfcpykjhdyjjaflash.huff", "-b", "-e", "shanghai"])
    │   │   └─ ← 0x<bytecode>
    │   ├─ [0] VM::prank(HuffConfig: [0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f])
    │   │   └─ ← ()
    │   ├─ [0] VM::ffi(["rm", "src/__TEMP__ihadllzrxbsnbidjjbjjfcpykjhdyjjaflash.huff"])
    │   │   └─ ← 0x
    │   ├─ [0] VM::broadcast()
    │   │   └─ ← you have an active prank; broadcasting and pranks are not compatible
    │   └─ ← you have an active prank; broadcasting and pranks are not compatible
    └─ ← you have an active prank; broadcasting and pranks are not compatible

It seems that the VM::prank call in creation_code messes up the broadcast. Was there a recent change in forge that breaks this?

Forge version I'm using: forge 0.2.0 (7922fd5 2024-02-05T00:17:19.307849379Z)

Here for same reason

Same for me too. Forge version: forge 0.2.0 (0c961f742 2024-04-07T02:15:21.084882963Z)

Most what I checked is coorect. But in this assembly part:

 assembly {
       let val := sload(value.slot)
       deployedAddress := create(val, add(concatenated, 0x20), mload(concatenated))
  }

We load indeed the correct storage and it is not empty, it contains the correct bytecode. But for some reason, the code "create" doesn't put the bytecode in the contract address and we still get a success with deployed contract but that its code is empty.