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

fix(anvil): tag newly created legacy transactions on shadow fork as Some(0) (0x0) rather than None #9195

Merged
merged 3 commits into from
Oct 25, 2024

Conversation

zerosnacks
Copy link
Member

@zerosnacks zerosnacks commented Oct 25, 2024

Motivation

Closes: #9194

Solution

Mark legacy transaction type as 0x0 or Some(0) rather than None

This is in line with how Alloy marks legacy transactions

Steps to test:

1. make build
2. ./target/debug/anvil --block-time 12 --port 8545 --fork-url <SEPOLIA_API_KEY>

In other window send a new transaction w/ default Anvil keys):

3. cast send 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 0x --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --legacy
4. cast tx <TX_HASH> --json | jq

To verify the fix run step 2 with latest anvil install

Will now correctly yield:

{
  "hash": "0x4dd5234b264e33221ef96a782163da179dcdc86a33f36f368aff8464ff17baa8",
  "nonce": "0x2f9a",
  "blockHash": "0x85ee456c35a65eccbd00ce99071a7aa79779770a52257cbaef4ef267f27254d8",
  "blockNumber": "0x69ed48",
  "transactionIndex": "0x0",
  "from": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
  "to": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
  "value": "0x0",
  "gasPrice": "0xe7f2d0db",
  "gas": "0x5209",
  "input": "0x",
  "r": "0xfe3f4a9323506eb34d6e38d15eebdfee9999d9355a40de7107cb19ad652623ae",
  "s": "0xdb65c223098cd4b7c8a032cc3958eb609fc1d0db7b64e83cacde5ace2217e99",
  "v": "0x1546d72",
  "chainId": "0xaa36a7",
  "type": "0x0"
}

as opposed to

{
  "hash": "0xe29dedc1f322c74923c409e5a4c66db6a9106d4ba765c7ba35c63bbdd826346e",
  "nonce": "0x2f9a",
  "blockHash": "0xf5836152445dc0421b15e0e3a4de9f37a0e85361fe6d9913497c2b7181876e88",
  "blockNumber": "0x69ed4e",
  "transactionIndex": "0x0",
  "from": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
  "to": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
  "value": "0x0",
  "gasPrice": "0x10abcce5d",
  "gas": "0x5209",
  "input": "0x",
  "r": "0x950a20008eb86b40c582ed1b909e30cea67a887bf04202507213000efef99ea8",
  "s": "0x7f3e167a3281e08823d5900847236505627bbf590fe8c9b45a61a78e3c4b2a68",
  "v": "0x1546d72",
  "chainId": "0xaa36a7"
}

When querying existing legacy transactions the transaction_type is already correctly marked as 0x0.

@zerosnacks zerosnacks changed the title fix(anvil): tag legacy transactions as Some(0) (0x0) rather than None fix(anvil): tag legacy transactions as Some(0) (0x0) rather than None Oct 25, 2024
@zerosnacks zerosnacks changed the title fix(anvil): tag legacy transactions as Some(0) (0x0) rather than None fix(anvil): tag newly created legacy transactions as Some(0) (0x0) rather than None Oct 25, 2024
@zerosnacks zerosnacks changed the title fix(anvil): tag newly created legacy transactions as Some(0) (0x0) rather than None fix(anvil): tag newly created legacy transactions on shadow fork as Some(0) (0x0) rather than None Oct 25, 2024
@zerosnacks zerosnacks marked this pull request as ready for review October 25, 2024 10:34
@zerosnacks zerosnacks requested a review from klkvr October 25, 2024 11:37
@zerosnacks zerosnacks enabled auto-merge (squash) October 25, 2024 12:32
@zerosnacks zerosnacks merged commit 192a5a2 into master Oct 25, 2024
21 checks passed
@zerosnacks zerosnacks deleted the zerosnacks/fix-tx-type-legacy-anvil branch October 25, 2024 14:01
rplusq pushed a commit to rplusq/foundry that referenced this pull request Nov 29, 2024
… `Some(0)` (`0x0`) rather than `None` (foundry-rs#9195)

* mark legacy transaction type as 0x0 or Some(0) rather than None

* return as Some(0) for legacy tx

* revert Some(0) change per EIP-2718 spec
@grandizzy grandizzy added T-bug Type: bug C-anvil Command: anvil labels Dec 18, 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
Archived in project
Development

Successfully merging this pull request may close these issues.

Missing tx type in eth_getTransactionByHash response
3 participants