Skip to content

InvalidFEOpcode does not revert after consuming all the gas #10884

Closed as not planned
@r0ohafza

Description

@r0ohafza

Component

Forge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

1.2.3-nightly

What version of Foundryup are you on?

No response

What command(s) is the bug in?

forge test

Operating System

macOS (Apple Silicon)

Describe the bug

Hello team,

Hi team,

I came across an unexpected behavior in a mainnet forked tests. Here’s a summary:

I wrote a test to distribute the USDT token on mainnet, in the distribute call the contract makes an external call wrapped in a try catch, this call fails because of incorrect approval in the USDT contract as also seen here.

In the trace below, the test does not revert after encountering this invalidOpcode, which seems counterintuitive. Although the opcode is wrapped in a try/catch, the subsequent assert fails and consumes all the gas—so I would expect the test to revert due to an out-of-gas error.

However, the test continues to pass unexpectedly. This behavior doesn’t align with what happens on mainnet, where the same transaction does revert because of OOG. You can see a real mainnet trace for reference here:
Mainnet Tenderly trace

I would expect the test to revert here as it consumes all the gas but because of foundry's high gas limits it doesn't.

Thanks!

    ├─ [61395971] 0x47529A57343d9ABA6d24E89970d53a15c68F3780::distribute(Split({ recipients: [0xa7128c450131A6a39751D1B0E2aA44f21B55Ea73, 0xAe4B8c350BB31ce40eaf75F154a2d354450cBe0f], allocations: [500000 [5e5], 500000 [5e5]], totalAllocation: 1000000 [1e6], distributionIncentive: 0 }), 0xdAC17F958D2ee523a2206206994597C13D831ec7, 0x0F17233C18aEB1278C6814b979a37031d123cFB8)
    │   ├─ [61395718] PullSplit::distribute(Split({ recipients: [0xa7128c450131A6a39751D1B0E2aA44f21B55Ea73, 0xAe4B8c350BB31ce40eaf75F154a2d354450cBe0f], allocations: [500000 [5e5], 500000 [5e5]], totalAllocation: 1000000 [1e6], distributionIncentive: 0 }), 0xdAC17F958D2ee523a2206206994597C13D831ec7, 0x0F17233C18aEB1278C6814b979a37031d123cFB8) [delegatecall]
    │   │   ├─ [1031] 0xdAC17F958D2ee523a2206206994597C13D831ec7::balanceOf(0x47529A57343d9ABA6d24E89970d53a15c68F3780) [staticcall]
    │   │   │   └─ ← [Return] 3625000000 [3.625e9]
    │   │   ├─ [2457] 0x8fb66F38cF86A3d5e8768f8F1754A24A6c661Fb8::balanceOf(0x47529A57343d9ABA6d24E89970d53a15c68F3780, 1248875146012964071876423320777688075155124985543 [1.248e48]) [staticcall]
    │   │   │   └─ ← [Return] 0
    │   │   ├─ [61269599] 0x8fb66F38cF86A3d5e8768f8F1754A24A6c661Fb8::deposit(0x47529A57343d9ABA6d24E89970d53a15c68F3780, 0xdAC17F958D2ee523a2206206994597C13D831ec7, 3624999999 [3.624e9])
    │   │   │   ├─ [5990] 0xdAC17F958D2ee523a2206206994597C13D831ec7::transferFrom(0x47529A57343d9ABA6d24E89970d53a15c68F3780, 0x8fb66F38cF86A3d5e8768f8F1754A24A6c661Fb8, 3624999999 [3.624e9])
    │   │   │   │   └─ ← [InvalidFEOpcode] EvmError: InvalidFEOpcode
    │   │   │   └─ ← [Revert] SafeERC20: low-level call failed
    │   │   ├─ [24953] 0xdAC17F958D2ee523a2206206994597C13D831ec7::approve(0x8fb66F38cF86A3d5e8768f8F1754A24A6c661Fb8, 115792089237316195423570985008687907853269984665640564039457584007913129639935 [1.157e77])
    │   │   │   ├─ emit Approval(owner: 0x47529A57343d9ABA6d24E89970d53a15c68F3780, spender: 0x8fb66F38cF86A3d5e8768f8F1754A24A6c661Fb8, value: 115792089237316195423570985008687907853269984665640564039457584007913129639935 [1.157e77])
    │   │   │   ├─  storage changes:
    │   │   │   │   @ 0xc9949d14608ff51c7e6dbd72217bbde212f4d6cc4bb4a35c49856596027f2bd1: 0 → 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
    │   │   │   └─ ← [Stop]
    │   │   ├─ [36030] 0x8fb66F38cF86A3d5e8768f8F1754A24A6c661Fb8::deposit(0x47529A57343d9ABA6d24E89970d53a15c68F3780, 0xdAC17F958D2ee523a2206206994597C13D831ec7, 3624999999 [3.624e9])
    │   │   │   ├─ [11730] 0xdAC17F958D2ee523a2206206994597C13D831ec7::transferFrom(0x47529A57343d9ABA6d24E89970d53a15c68F3780, 0x8fb66F38cF86A3d5e8768f8F1754A24A6c661Fb8, 3624999999 [3.624e9])
    │   │   │   │   ├─ emit Transfer(from: 0x47529A57343d9ABA6d24E89970d53a15c68F3780, to: 0x8fb66F38cF86A3d5e8768f8F1754A24A6c661Fb8, value: 3624999999 [3.624e9])
    │   │   │   │   ├─  storage changes:
    │   │   │   │   │   @ 0x749ff53b89e254d35733bd0659c7bf5cdb121722d8a57c8451b321e5fc77378f: 0x00000000000000000000000000000000000000000000000000000000003bb90f → 0x00000000000000000000000000000000000000000000000000000000d84cd54e
    │   │   │   │   │   @ 0x1af0417bbd841150879868c0f2f84a56cf762ca2dc33902011378e9fd28f0c95: 0x00000000000000000000000000000000000000000000000000000000d8111c40 → 1
    │   │   │   │   └─ ← [Stop]
    │   │   │   ├─ emit Transfer(caller: 0x47529A57343d9ABA6d24E89970d53a15c68F3780, sender: 0x0000000000000000000000000000000000000000, receiver: 0x47529A57343d9ABA6d24E89970d53a15c68F3780, id: 1248875146012964071876423320777688075155124985543 [1.248e48], amount: 3624999999 [3.624e9])
    │   │   │   ├─  storage changes:
    │   │   │   │   @ 0x6633457b6c22a2096ad4ead667ba3b83783442113fe0ad503b32a174ea6c708c: 0 → 0x00000000000000000000000000000000000000000000000000000000d8111c3f
    │   │   │   └─ ← [Stop]
    │   │   ├─ [51380] 0x8fb66F38cF86A3d5e8768f8F1754A24A6c661Fb8::batchTransfer([0xa7128c450131A6a39751D1B0E2aA44f21B55Ea73, 0xAe4B8c350BB31ce40eaf75F154a2d354450cBe0f], 0xdAC17F958D2ee523a2206206994597C13D831ec7, [1812499999 [1.812e9], 1812499999 [1.812e9]])
    │   │   │   ├─ emit Transfer(caller: 0x47529A57343d9ABA6d24E89970d53a15c68F3780, sender: 0x47529A57343d9ABA6d24E89970d53a15c68F3780, receiver: 0xa7128c450131A6a39751D1B0E2aA44f21B55Ea73, id: 1248875146012964071876423320777688075155124985543 [1.248e48], amount: 1812499999 [1.812e9])
    │   │   │   ├─ emit Transfer(caller: 0x47529A57343d9ABA6d24E89970d53a15c68F3780, sender: 0x47529A57343d9ABA6d24E89970d53a15c68F3780, receiver: 0xAe4B8c350BB31ce40eaf75F154a2d354450cBe0f, id: 1248875146012964071876423320777688075155124985543 [1.248e48], amount: 1812499999 [1.812e9])
    │   │   │   ├─  storage changes:
    │   │   │   │   @ 0x920441b8e2d68a5c4bc4da09ae8ae02a09c94656e04f3c8409f9406366b231d4: 0 → 0x000000000000000000000000000000000000000000000000000000006c088e1f
    │   │   │   │   @ 0x6633457b6c22a2096ad4ead667ba3b83783442113fe0ad503b32a174ea6c708c: 0x00000000000000000000000000000000000000000000000000000000d8111c3f → 1
    │   │   │   │   @ 0x3487167a9c4489368b113c24704cc561ad706fdc612494b73692937bf0c3d81b: 0 → 0x000000000000000000000000000000000000000000000000000000006c088e1f
    │   │   │   └─ ← [Stop]
    │   │   ├─ emit SplitDistributed(token: 0xdAC17F958D2ee523a2206206994597C13D831ec7, distributor: 0x0F17233C18aEB1278C6814b979a37031d123cFB8, amount: 3624999999 [3.624e9])
    │   │   └─ ← [Stop]
    │   └─ ← [Return]
    ├─ [1031] 0xdAC17F958D2ee523a2206206994597C13D831ec7::balanceOf(0x47529A57343d9ABA6d24E89970d53a15c68F3780) [staticcall]
    │   └─ ← [Return] 1
    ├─  storage changes:
    │   @ 33: 0x000000000000000000000000a0cb889707d426a7a386870a03bc70d1b0697598 → 0x000000000000000000000000d6bbde9174b1cdaa358d2cf4d57d1a9f7178fbff
    └─ ← [Stop]

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-bugType: bugT-needs-triageType: this issue needs to be labelledT-to-reproduceType: requires reproduction

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions