ava-labs / subnet-evm

Launch your own EVM as an Avalanche Subnet
https://docs.avax.network/subnets/create-a-fuji-subnet
GNU Lesser General Public License v3.0
237 stars 213 forks source link

eth_estimateGas calls with predicates #1196

Closed minghinmatthewlam closed 3 weeks ago

minghinmatthewlam commented 1 month ago

Describe the bug Making an eth_estimateGas call with a Warp message in its predicate fails with invalid warp message. Same Warp message sends fine when using NewPredicateTx followed by eth_sendTransaction.

To Reproduce

  1. Go to teleporter branch gas-estimate https://github.com/ava-labs/teleporter/tree/gas-estimate
  2. Run /scripts/local/e2e_test.sh
  3. Watch the test fail with invalid warp message

Expected behavior The test uses the same Warp message bytes that succeeds if you don't use estimateGas. Expect it to return gas estimate after seeing Warp message is valid.

Logs

[node1-bls] INFO [05-29|15:41:41.306] <2NFa5wVHJXg5gthTFJ165KgJTk3jL9gTA1NuXt3ncFVzY1sftF Chain> github.com/ava-labs/subnet-evm/rpc/handler.go:526: Served eth_estimateGas reqid=51 execTime=1.347541ms procTime=1.348667ms totalTime=1.348916ms err="execution reverted: TeleporterMessenger: invalid warp message" errdata=0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002954656c65706f727465724d657373656e6765723a20696e76616c69642077617270206d6573736167650000000000000000000000000000000000000000000000
  [FAILED] Expected
      <*rpc.jsonError | 0x140029c9020>:
      execution reverted: TeleporterMessenger: invalid warp message
      {
          Code: 3,
          Message: "execution reverted: TeleporterMessenger: invalid warp message",
          Data: <string>"0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002954656c65706f727465724d657373656e6765723a20696e76616c69642077617270206d6573736167650000000000000000000000000000000000000000000000",
      }
  to be nil
  In [It] at: /Users/matthewlam/go/src/teleporter/tests/utils/utils.go:330 @ 05/29/24 15:41:41.307

  Full Stack Trace
    github.com/ava-labs/teleporter/tests/utils.CreateReceiveCrossChainMessageTransaction({0x105f432b0, 0x107af96e0}, 0x1400286fc20, 0x14000f83920, {0x25, 0x3b, 0x27, 0x84, 0xc7, 0x5e, ...}, ...)
        /Users/matthewlam/go/src/teleporter/tests/utils/utils.go:330 +0x368
    github.com/ava-labs/teleporter/tests/local.(*LocalNetwork).RelayMessage(_, {_, _}, _, {{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...}, ...}, ...)
        /Users/matthewlam/go/src/teleporter/tests/local/network.go:428 +0x1e8
    github.com/ava-labs/teleporter/tests/flows.BasicSendReceive({0x105f507c8, 0x14001309360})
        /Users/matthewlam/go/src/teleporter/tests/flows/basic_send_receive.go:70 +0x628
    github.com/ava-labs/teleporter/tests/local.init.func3.6()
        /Users/matthewlam/go/src/teleporter/tests/local/e2e_test.go:103 +0x2c
  < Exit [It] Send a message from Subnet A to Subnet B, and one from B to A - /Users/matthewlam/go/src/teleporter/tests/local/e2e_test.go:100 @ 05/29/24 15:41:41.307 (5.631s)

Operating System mac

Additional context Add any other context about the problem here.

Avalanche Bug Bounty program can be found here.