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

bug(anvil): inconsistent simulation behaviour #7068

Open
2 tasks done
Tracked by #8269
DicksonWu654 opened this issue Feb 9, 2024 · 1 comment
Open
2 tasks done
Tracked by #8269

bug(anvil): inconsistent simulation behaviour #7068

DicksonWu654 opened this issue Feb 9, 2024 · 1 comment
Assignees
Labels
C-anvil Command: anvil T-bug Type: bug
Milestone

Comments

@DicksonWu654
Copy link

DicksonWu654 commented Feb 9, 2024

Component

Anvil

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (b174c3a 2024-02-09T00:16:22.953958126Z)

What command(s) is the bug in?

No response

Operating System

Linux

Describe the bug

Hi! I am experiencing inconsistent behaviour from anvil when simulating a transaction on an old block. There are 2 commands:
First set up anvil:

anvil --chain-id 1 --port 8545 --base-fee 1000 --fork-block-number 14684306 -f "<NODE_URL>"

Then run eth_sendUnsignedTransaction:

curl -X POST -H "Content-Type: application/json" --data \
'{
  "jsonrpc":"2.0",
  "method":"eth_sendUnsignedTransaction",
  "params":[{
    "from": "0x63341ba917de90498f3903b199df5699b4a55ac0",
    "to": "0x7336F819775B1D31Ea472681D70cE7A903482191",
    "data": "0xaf8271f7",
    "gas": "0x20EF3F",
    "gasPrice": "0x34257"
  }],
  "id":1
}' "http://127.0.0.1:8545"

You might need to run it several times but sometimes it succeeds (as it should) and sometimes it fails. To rerun it, re-run both commands again (to ensure anvil is at the right block level + so it's the same state):

Listening on 127.0.0.1:8545
eth_sendUnsignedTransaction

    Transaction: 0x83b8909a89584001b122eba49310f13a8c7dc690acbc8c7d90350494a1cf7537
    Gas used: 1815058

    Block Number: 14684307
    Block Hash: 0x3f59e4fa81cc720c5d0d7df38ac08fa650cd72c046fe665d428a0e3965595cb9
    Block Time: "Sat, 30 Apr 2022 07:40:14 +0000"

Other times it fails:

Listening on 127.0.0.1:8545
eth_sendUnsignedTransaction

    Transaction: 0x83b8909a89584001b122eba49310f13a8c7dc690acbc8c7d90350494a1cf7537
    Gas used: 2158038
    Error: reverted with: EvmError: Revert

    Block Number: 14684307
    Block Hash: 0x667ea63188956e7fe25fa2806d76651afb745b0c102cf3606c33eb398942c712
    Block Time: "Sat, 30 Apr 2022 07:40:07 +0000"

In general, I'm getting a lot of inconsistent behaviour from anvil VS simulating using trace_call using Erigon:

curl -X POST -H "Content-Type: application/json" --data \
'{
  "jsonrpc":"2.0",
  "method":"trace_call",            
  "params":[{
    "from": "0x63341ba917de90498f3903b199df5699b4a55ac0",
    "to": "0x7336F819775B1D31Ea472681D70cE7A903482191",
    "data": "0xaf8271f7",
    "gas": "0x20EF3F",
    "gasPrice": "0x34257"
  }, ["trace"], "0xE01092"], 
  "id":1
}' "<NODE_URL>"

This succeeds every single time I run it.

(Also the txn I'm replicating in this instance is: "0x2b023d65485c4bb68d781960c2196588d03b871dc9eb1c054f596b7ca6f7da56")

Anvil isn't just failing on this txn, it's failing on many txns across the entire history of the chain.

Thank you in advance!

@DicksonWu654 DicksonWu654 added the T-bug Type: bug label Feb 9, 2024
@mattsse mattsse self-assigned this Feb 9, 2024
@BowTiedDevil
Copy link

I am encountering this behavior, too. I am forking from mainnet block 19922506 and replaying the first two transactions from the next block:
TX 0: 0xce3acf3eeebd6ff6ab7b574c1ef15057b09845254bab110c4afee0c898dfb8d5
TX 1: 0x6c9ec85db14f593dd2290c3be7d067e7e3cce7831d1a03db2004b5dd540180d5

With auto-impersonate active, I can send both transactions in sequence. Consistently, TX 0 completes and TX 1 reverts. This pattern happens using both eth_sendTransaction and eth_sendRawTransaction.

Both transactions confirm as expected when sent to a Hardhat node with similar options.

I tested several old nightly releases via foundryup -v back to Jan 2023 to observe the same behavior.

@zerosnacks zerosnacks added the C-anvil Command: anvil label Jun 27, 2024
@zerosnacks zerosnacks changed the title Inconsistent Anvil Simulation Behaviour bug(anvil): inconsistent simulation behaviour Jul 11, 2024
@zerosnacks zerosnacks added this to the v1.0.0 milestone Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-anvil Command: anvil T-bug Type: bug
Projects
No open projects
Status: Todo
Development

No branches or pull requests

4 participants