kkrt-labs / kakarot-rpc

Kakarot ZK EVM Ethereum RPC adapter
MIT License
136 stars 99 forks source link

feat: eth_getTransactionCount #101

Closed Eikix closed 1 year ago

Eikix commented 1 year ago

eth_getTransactionCount

Specification Description

Requests a specific account's number of transactions, in order to compute its nonce.

Parameters

Returns

Kakarot Logic

Call the Starknet starknet_getNonce json rpc method. Return it.

github-actions[bot] commented 1 year ago

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a 👍 Because this issue is marked as stale, it will be closed and locked in 7 days if no further activity occurs. Thank you for your contributions!

internnos commented 1 year ago

hi i'd like to take this issue!

Eikix commented 1 year ago

hey @internnos ! happy to see you here,

I believe the correct way to go about this issue is to grab the nonce of a particular starknet address using the starknet-rpc endpoint.

you can draw inspiration from the current architecture and other methods. but essentially:

  1. grab the ethereum address received, and ask Kakarot to compute the corresponding starknet address (using compute_starknet_address)
  2. call the starknet rpc method get_nonce https://github.com/starkware-libs/starknet-specs/blob/master/api/starknet_api_openrpc.json#L629
  3. return the correctly formed payload (as per the spec) https://ethereum.github.io/execution-apis/api-documentation/
internnos commented 1 year ago

hey @internnos ! happy to see you here,

I believe the correct way to go about this issue is to grab the nonce of a particular starknet address using the starknet-rpc endpoint.

you can draw inspiration from the current architecture and other methods. but essentially:

  1. grab the ethereum address received, and ask Kakarot to compute the corresponding starknet address (using compute_starknet_address)
  2. call the starknet rpc method get_nonce https://github.com/starkware-libs/starknet-specs/blob/master/api/starknet_api_openrpc.json#L629
  3. return the correctly formed payload (as per the spec) https://ethereum.github.io/execution-apis/api-documentation/

happy to see you again @Eikix !

gotcha, on it! thanks for the suggestion!

internnos commented 1 year ago

i have a question @Eikix

according to this the signature of compute_starknet_address needs starknet_block_id

however, during the computation of transaction_count, ethereum_block_id is not required

https://ethereum.github.io/execution-apis/api-documentation/

Screenshot 2023-04-08 at 2 01 05 pm

but when i tried without the ethereum_block_id, i got the following error

 {
    "jsonrpc": "2.0",
    "id": 0,
    "error": {
        "code": -32602,
        "message": "missing value for required argument 1"
    }
}

does it mean that the ethereum spec docs is incorrect in this part?

ClementWalter commented 1 year ago

hey @internnos , so I used the https://composer.alchemy.com/ tool to make a smol test and this param is actually not required, see corresponding curl request

$ curl 'https://eth-mainnet.g.alchemy.com/v2/18lHSAeZttzI4wJvHpXlJGHK4ZDNCTCP' \
  -H 'content-type: application/json' \
  --data-raw '{"jsonrpc":"2.0","id":0,"method":"eth_getTransactionCount","params":["0xabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd"]}' \
  --compressed

{"jsonrpc":"2.0","id":0,"result":"0x0"}%

which means that we should handle this in the RPC as well. Not providing the block means "latest" btw

internnos commented 1 year ago

hey @internnos , so I used the https://composer.alchemy.com/ tool to make a smol test and this param is actually not required, see corresponding curl request

$ curl 'https://eth-mainnet.g.alchemy.com/v2/18lHSAeZttzI4wJvHpXlJGHK4ZDNCTCP' \
  -H 'content-type: application/json' \
  --data-raw '{"jsonrpc":"2.0","id":0,"method":"eth_getTransactionCount","params":["0xabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd"]}' \
  --compressed

{"jsonrpc":"2.0","id":0,"result":"0x0"}%

which means that we should handle this in the RPC as well. Not providing the block means "latest" btw

aah thanks for the clarity. all clear now, thanks @ClementWalter!

github-actions[bot] commented 1 year ago

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a 👍 Because this issue is marked as stale, it will be closed and locked in 7 days if no further activity occurs. Thank you for your contributions!