Giter Club home page Giter Club logo

kakarot-rpc's People

Contributors

abdelstark avatar alex-sumner avatar aniketpr01 avatar apoorvsadana avatar bajpai244 avatar bhavyagosai avatar clementwalter avatar d-roak avatar danilowhk avatar dependabot[bot] avatar dznes avatar edisontim avatar eikix avatar enitrat avatar etashhh avatar eugypalu avatar ftupas avatar gerson2102 avatar greged93 avatar imotai avatar irisdv avatar jobez avatar omahs avatar pablovillaplana avatar stevencartavia avatar swetshaw avatar tadev0 avatar tcoratger avatar tekkac avatar zarboq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

kakarot-rpc's Issues

bug: Fix `decode_execute_at_address`

Bug Report

decode_execute_at_address_return is out-of-date compared to the latest version of Kakarot.
Update it in order to properly parse the return params of Kakarot.

https://github.com/sayajin-labs/kakarot-rpc/blob/473acf45c7cff82e66ecc0606637deab029f4e23/core/src/helpers.rs#L343

https://github.com/sayajin-labs/kakarot/blob/ca7fb83adf4d91e2c2bc911a940af2a1fe5749b6/src/kakarot/kakarot.cairo#L112

There is now a last argument gas_used in Kakarot execute_at_address return payload

Choose the ChainID

What chainID should we choose for the RPC ? I first though of 9001 because it's over 9000 but EVMOS already took it.

So 9000 as a fallback but seems not satisfying

Propose your ideas

feat: Kakarot Rpc method "eth_getBlockByHash"

eth_getBlockByHash

Metadata

Specification Description

Describe the method

Parameters

  • None

Returns

  • uint64 - e.g. blockNumber

Kakarot Logic

Describe the interaction with Kakarot and/or Starknet.
e.g. "this method does not interact with the kakarot contract or any other starknet contract."

Kakarot methods

Which Kakarot methods are called?

Starknet methods

Which Starknet RPC methods are called? e.g. "Would be calling the corresponding starknet_getBlockByHash https://github.com/starkware-libs/starknet-specs/blob/master/starknet_vs_ethereum_node_apis.md"

method:net_version

net_version

Metadata

Specification Description

Returns the current network id.

Parameters

  • None

Returns

  • String - the current network id

Kakarot Logic

This method does not interact with the kakarot contract or any other starknet contract. The method returns a constant variable name CHAIN_ID which needs to be determined see this issue.

Kakarot methods

Starknet methods

feat: eth_getTransactionCount

eth_getTransactionCount

  • name: getTransactionCount
  • prefix: eth
  • state: ⚠️
  • specification

Specification Description

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

Parameters

  • Address
  • Block

Returns

  • uint256 - e.g. Transaction Count

Kakarot Logic

Call the Starknet starknet_getNonce json rpc method. Return it.

feat: eth_getBalance

eth_getBalance

Metadatax

Specification Description

Describe the method

Parameters

  • None

Returns

  • uint64 - e.g. blockNumber

Kakarot Logic

Describe the interaction with Kakarot and/or Starknet.
e.g. "this method does not interact with the kakarot contract or any other starknet contract."

Kakarot methods

Which Kakarot methods are called?

Starknet methods

Which Starknet RPC methods are called? e.g. "Would be calling the corresponding starknet_blockNumber https://github.com/starkware-libs/starknet-specs/blob/master/starknet_vs_ethereum_node_apis.md"

feat: eth_syncing

<METHOD_NAME>

Metadatax

Specification Description

Describe the method

Parameters

  • None

Returns

  • SyncStatus

Kakarot Logic

Does not interact with Kakarot

Starknet methods

Calls Syncing in Starknet light client

feat: eth_accounts

eth_accounts

Metadata

Specification Description

Returns a list of accounts owned by the client.

Parameters

  • None

Returns

  • uint64 - e.g. blockNumber

Kakarot Logic

No Kakarot logic.

For now, returns an empty Vector.

feat: kakarot_getTokenBalances

kakarot_getTokenBalances

Metadata

  • name: getTokenBalances
  • prefix: kakarot
  • state: ⚠️
  • specification

Specification Description

Returns token balances for a specific address given a list of contracts.

Parameters

  • address: The address for which token balances will be checked.
  • contractAddresses: An array of contract addresses.

Returns

An object with the following fields:

  • address: The address for which token balances were checked.
  • tokenBalances: An array of token balance objects. Each object contains:
    • contractAddress: The address of the contract.
    • tokenBalance: The balance of the contract, as a string representing a base-10 number.
    • error: An error string. Either error or tokenBalance will be null.

Kakarot Logic

Calls Kakarot execute_at_address with "call signature" once for each contractAddresses index -> calls balanceOf(address owner) with parameter owner == address.
Reconstructs the return format.

Kakarot methods

Call execute_at_address n times,n == contractAddresses.len()

feat: Kakarot Rpc method "eth_getTransactionCount" #16

eth_getTransactionCount

Metadata

  • name: getTransactionCount
  • prefix: eth
  • state: ⚠️
  • specification

Specification Description

Describe the method

Parameters

  • None

Returns

  • uint64 - e.g. blockNumber

Kakarot Logic

Describe the interaction with Kakarot and/or Starknet.
e.g. "this method does not interact with the kakarot contract or any other starknet contract."

Kakarot methods

Which Kakarot methods are called?

Starknet methods

Which Starknet RPC methods are called? e.g. "Would be calling the corresponding starknet_getTransactionCount https://github.com/starkware-libs/starknet-specs/blob/master/starknet_vs_ethereum_node_apis.md"

feat: Kakarot Rpc method "eth_getTransactionReceipt"

eth_getTransactionReceipt

Metadata

  • name: getTransactionReceipt
  • prefix: eth
  • state: ⚠️
  • specification

Specification Description

Describe the method

Parameters

  • Address : address
  • Block : BlockTag

Returns

  • BlockCount : uint

Kakarot Logic

Describe the interaction with Kakarot and/or Starknet.
e.g. "this method does not interact with the kakarot contract or any other starknet contract."

Kakarot methods

Which Kakarot methods are called?

Starknet methods

Which Starknet RPC methods are called? e.g. "Would be calling the corresponding starknet_getTransactionReceipt https://github.com/starkware-libs/starknet-specs/blob/master/starknet_vs_ethereum_node_apis.md"

feat: Handle gas_used / gas_price / baseFee and other gas related variables

Feature Request

Describe the Feature Request

Ethereum JSON RPC spec manipulates various variables linked with gas -> gas_used, gas_price, baseFee, priorityFee etc.
Currently, Starknet does not have a market for gas but rather fixed gas prices as per a formula https://docs.starknet.io/documentation/architecture_and_concepts/Fees/fee-mechanism/

There are some challenges to separate actual_fee (variable caught from starknet transaction receipt) and separate it between gas_used and gas_price (baseFee + priorityFee)

Wherever gas_used / gas_price are used, should find a way them from derive actual_fee and max_fee

feat: Kakarot Rpc method "eth_gasPrice"

eth_gasPrice

Metadata

Specification Description

Describe the method

Parameters

  • None

Returns

  • GasPrice : uint

Kakarot Logic

Describe the interaction with Kakarot and/or Starknet.
e.g. "this method does not interact with the kakarot contract or any other starknet contract."

Kakarot methods

Which Kakarot methods are called?

Starknet methods

Which Starknet RPC methods are called? e.g. "Would be calling the corresponding starknet_gasPrice https://github.com/starkware-libs/starknet-specs/blob/master/starknet_vs_ethereum_node_apis.md"

Kakarot Rpc method "eth_getBlockByNumber"

eth_getBlockByNumber

Metadata

Specification Description

Describe the method

Parameters

  • block_number

Returns

  • Block

Kakarot Logic

Describe the interaction with Kakarot and/or Starknet.
e.g. "this method does not interact with the kakarot contract or any other starknet contract."

Kakarot methods

Which Kakarot methods are called?

Starknet methods

Which Starknet RPC methods are called? e.g. "Would be calling the corresponding starknet_getBlockByNumber https://github.com/starkware-libs/starknet-specs/blob/master/starknet_vs_ethereum_node_apis.md"

method: eth_blockNumber

eth_blockNumber

Metadata

Specification Description

Returns the number of most recent block.

Parameters

  • None

Returns

  • uint64 - blockNumber

Kakarot Logic

This method does not interact with the kakarot contract or any other starknet contract.

Kakarot methods

Starknet methods

Would be calling the corresponding starknet_blockNumber https://github.com/starkware-libs/starknet-specs/blob/master/starknet_vs_ethereum_node_apis.md

feat: Fix blockByNumber when "full_txs" = true

Feature Request

Currently we are getting an error when calling blockByNumber with full_txs = true, only full_txs = false is working, fix to return full txs data correctly.

Describe Preferred Solution

Describe Alternatives

Related Code

Additional Context

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No

feat: write down Kakarot "logs" into the transaction_receipt.logs

Feature Request

Describe the Feature Request

Convert starknet transaction receipt logs to be EVM-format 'friendly' so it can be used in transaction_receipt.

Describe Preferred Solution

Describe Alternatives

Related Code

Additional Context

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No

feat: Go from PrimitiveH256 and H256 to only one H256 type

Feature Request

Describe the Feature Request

We currently use reth_primitives::H256 and reth_primitives::rpc::H256 types which create mismatch errors.

Currently we import both types :

use reth_primitives::{
    rpc::H256,
    H256 as PrimitiveH256,
};

reth_primitives::rpc::H256 is reexported from ethers-rs, we should use the main reth_primitives::H256 type instead which is a ruint::H256.

Describe Preferred Solution

Use reth_primitives::H256 in the repo.

Doing this currently results in an error when using reth_primitives::rpc::BlockId::Hash as it's reexported from ethers which uses primitives_types::H256 and not ruint::H256. An issue is opened on reth repo to add a reth native BlockId type.

Describe Alternatives

In the meantime a workaround would be to use H256::from(val.0)

Related Code

Additional Context

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No

dev: update eth_getBlockTransactionCountByHash & byNumber to use starknet_getBlockTransactionCount

Currently eth_getBlockTransactionCountByHash and eth_getBlockTransactionCountByNumber functions both fetch starknet_getBlockWithTxHashes endpoint and then count the number of transactions in the block. When block is pending, both endpoints do not return anything.

Both functions should use starknet_getBlockTransactionCount which returns the number of transactions for accepted and pending blocks.

feat: Kakarot Rpc method "eth_estimateGas"

eth_estimateGas

Metadatax

Specification Description

Describe the method

Parameters

  • Transaction : Transaction
  • Block : Blocktag

Returns

  • GasUsed : uint

Kakarot Logic

Describe the interaction with Kakarot and/or Starknet.
e.g. "this method does not interact with the kakarot contract or any other starknet contract."

Kakarot methods

Which Kakarot methods are called?

Starknet methods

Which Starknet RPC methods are called? e.g. "Would be calling the corresponding starknet_estimateGas https://github.com/starkware-libs/starknet-specs/blob/master/starknet_vs_ethereum_node_apis.md"

feat: Kakarot Rpc method "eth_getLogs"

eth_getLogs

Metadata

Specification Description

Describe the method

Parameters

  • None

Returns

  • uint64 - e.g. blockNumber

Kakarot Logic

Describe the interaction with Kakarot and/or Starknet.
e.g. "this method does not interact with the kakarot contract or any other starknet contract."

Kakarot methods

Which Kakarot methods are called?

Starknet methods

Which Starknet RPC methods are called? e.g. "Would be calling the corresponding starknet_getLogs https://github.com/starkware-libs/starknet-specs/blob/master/starknet_vs_ethereum_node_apis.md"

method:eth_chainId

eth_chainId

Metadata

Specification Description

Returns the chain ID of the current network.

Parameters

  • None

Returns

  • uint - chainId

Kakarot Logic

This method does not interact with the kakarot contract or any other starknet contract. The method returns a constant variable name CHAIN_ID which needs to be determined see this issue.

Kakarot methods

Starknet methods

method:web3_sha3

web3_sha3

Metadata

Specification Description

Returns Keccak-256 (not the standardized SHA3-256) of the given data.

Parameters

  • DATA - bytes - the data to convert into a SHA3 hash

Returns

  • u256 - the data to convert into a SHA3 hash

Kakarot Logic

This method does not interact with the kakarot contract or any other starknet contract. This method uses the rust-crypto package to hash the provided bytes with the keccak256 hash algorithm. The hex data provided was previously parsed by the hex utils.

Kakarot methods

Starknet methods

feat: Kakarot Rpc method "eth_call"

eth_call

Metadata

Specification Description

Describe the method

Parameters

  • transaction_data

Returns

  • return_data

Kakarot Logic

Describe the interaction with Kakarot and/or Starknet.
e.g. "this method does not interact with the kakarot contract or any other starknet contract."

Kakarot methods

Which Kakarot methods are called?

Starknet methods

Which Starknet RPC methods are called? e.g. "Would be calling the corresponding starknet_call https://github.com/starkware-libs/starknet-specs/blob/master/starknet_vs_ethereum_node_apis.md"

feat: properly handle transaction hashes

Feature Request

Describe the Feature Request

Currently, we don't handle discrepancies between EVM transaction hashes vs. Starknet transaction hashes. We should programmatically "know" whether a user is manipulating starknet tx hashes or evm tx hashes, and return the correct hash.

Example:
1.
User calls getTransactionReceipt, they will use an EVM tx hash, as this is the return value they get when calling eth_sendRawTransaction.

Thus, we need a deterministic mapping between an EVM tx hash and the resulting Starknet tx hash

feat: Kakarot Rpc method "eth_getCode"

eth_getCode

Metadatax

Specification Description

Describe the method

Parameters

  • Address : Address
  • Block : BlockTag

Returns

-Bytecode : bytes

Kakarot Logic

Describe the interaction with Kakarot and/or Starknet.
e.g. "this method does not interact with the kakarot contract or any other starknet contract."

Kakarot methods

Which Kakarot methods are called?

Starknet methods

Which Starknet RPC methods are called? e.g. "Would be calling the corresponding starknet_getCode https://github.com/starkware-libs/starknet-specs/blob/master/starknet_vs_ethereum_node_apis.md"

method:net_listening

net_listening

Metadata

Specification Description

Returns true if client is actively listening for network connections.

Parameters

  • None

Returns

  • boolean - true when listening, otherwise false.

Kakarot Logic

For the moment, Kakarot is not a layer 3 so not a dedicated network. The RPC is not connected to any specific network with other nodes except to starknet. So as a temporary solution it returns true if the connection is successful with the starknet RPC and if not it returns false.

Kakarot methods

Starknet methods

dev: delete types file and import only reth types

Currently, for speed / simplicity, we replicated types from eth inside types.rs

Let's delete them all and use only the reth types. Either reth_primitives or reth_primitives::rpc depending on our need.

We still need to discover whether or not reth_rpc::types will disappear as they suggested it was tech debt

bug: handle Starknet signatures conversion to `r, s, v` parameters in Ethereum

Bug Report

Currently, we convert the signature array from starknet transactions to r, s, v parameters that are used in ECDSA.
Currently, signatures has only two items, example of a starknet tx:

{
        "calldata": [
          "0x1",
          "0x4a3621276a83251b557a8140e915599ae8e7b6207b067ea701635c0d509801e",
          "0x2d4c8ea4c8fb9f571d1f6f9b7692fff8e5ceaf73b1df98e7da8c1109b39ae9a",
          "0x0",
          "0x2",
          "0x2",
          "0x4767b873669406d25dddbf67356e385a14480979e5358a411955d692576aa30",
          "0x1"
        ],
        "max_fee": "0x11b1d9007c05c",
        "nonce": "0x18",
        "sender_address": "0xd90fd6aa27edd344c5cbe1fe999611416b268658e866a54265aaf50d9cf28d",
        "signature": [
          "0x3cd4f193f84704ce73cfb45abcdb0a169067b56821b267b9af6eb52531c94dc",
          "0x6e0fac18be9cddae718054b6fe1cf7448015c1ef5a4fa5a7919665e0126e585"
        ],
        "transaction_hash": "0x65eee3bd22766c75d5e5f55c747db41d192d0274a5579d8808b2c5850dd0f6a",
        "type": "INVOKE",
        "version": "0x1"
      },

Current behavior:

The bug manifests as, when transforming to Ethereum transactions, we do:

// Extracting the signature
ether_tx.r = felt_option_to_u256(v1.signature.get(0))?;
ether_tx.s = felt_option_to_u256(v1.signature.get(1))?;
ether_tx.v = felt_option_to_u256(v1.signature.get(2))?;

Expected behavior:

insert short code snippets here


We should find a way to properly map `r, s, v` args in our transaction reports

feat: eth_getWork

eth_getWork

Metadatax

Specification Description

getWork in PoW -> useless for PoS

method:web3_clientVersion

web3_clientVersion

Metadata

Specification Description

Returns the current client version.

Parameters

  • None

Returns

  • String - Version of the client

Kakarot Logic

This method does not interact with the kakarot contract or any other starknet contract. Instead it will return the version of this repository with this format:

kakarot-rpc-adapter/vX.X.X/OS/rustX.X.X

Kakarot methods

Starknet methods

feat: Kakarot Rpc method "eth_chainId"

eth_chainId

Metadata

Specification Description

Describe the method

Parameters

  • None

Returns

  • ChainId - uint

Kakarot Logic

Describe the interaction with Kakarot and/or Starknet.
e.g. "this method does not interact with the kakarot contract or any other starknet contract."

Kakarot methods

Which Kakarot methods are called?

Starknet methods

Which Starknet RPC methods are called? e.g. "Would be calling the corresponding starknet_chainId https://github.com/starkware-libs/starknet-specs/blob/master/starknet_vs_ethereum_node_apis.md"

feat: Refactor starknet_address_to_ethereum_address

Feature Request

Describe the Feature Request

starknet_address_to_ethereum_address helper function is used to get the EVM address of a Kakarot contract (be it an ExternallyOwnedAccount or a Contract account).
Currently starknet_address_to_ethereum_address takes the last 20 bytes to represent a starknet address as an EVM address. However, all Kakarot contracts (EVM smart contracts or accounts) have a view method called get_evm_address.

Describe Preferred Solution

Describe Alternatives

Related Code

Additional Context

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No

feat: add Kakarot-only transactions filtering on eth_getBlockByNumber AND eth_getBlockByHash

Feature Request

Currently, eth_getBlockByNumber and eth_getBlockByHash return a Starknet block in the format of an EVM block-ish (some loss of information, and inserted zeroes).

We'd need to filter for Starknet transactions that interacted with Kakarot.
If there are no Kakarot transactions in a Block, we may return an empty Block.

Describe the Feature Request

Describe Preferred Solution

Describe Alternatives

Related Code

Additional Context

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No

dev: refactor async for loops and try_join_all into join_all

Currently we have the need to loop over futures.

We should use the idiomatic join_all method on futures instead of for loops.

try_join_all is suboptimal for our use case as it returns a Result<Vec<_>> meaning that it requires all the calls to succeed.

join_all returns a Vec<Result<_>> which lets you handle every case in a singular way.

Task: replace all For loops on Async Futures by futures::join_all and handle properly error cases for each vector element.

feat: add testing management to the repo

Feature Request

Describe the Feature Request

Describe Preferred Solution

Describe Alternatives

Related Code

Additional Context

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No

feat: eth_getStorageAt

eth_getStorageAt

Metadatax

Specification Description

Implementing eth_getStorageAt, quite similar way to eth_getCode method

feat: Kakarot Rpc method "eth_sendRawTransaction"

eth_sendRawTransaction

Metadatax

  • name: sendRawTransaction
  • prefix: eth
  • state: ⚠️
  • specification

Specification Description

Describe the method

Parameters

  • Transaction : bytes

Returns

  • TransactionHash : hash32

Kakarot Logic

Describe the interaction with Kakarot and/or Starknet.
e.g. "this method does not interact with the kakarot contract or any other starknet contract."

Kakarot methods

Which Kakarot methods are called?

Starknet methods

Which Starknet RPC methods are called? e.g. "Would be calling the corresponding starknet_sendRawTransaction https://github.com/starkware-libs/starknet-specs/blob/master/starknet_vs_ethereum_node_apis.md"

method:net_peerCount

net_peerCount

Metadata

Specification Description

Returns the number of peers currently connected to the client.

Parameters

  • None

Returns

  • Number - unsigned integer of the number of connected peers.

Kakarot Logic

For the moment, Kakarot is not a layer 3 so not a dedicated network. The RPC is not connected to any specific network with other nodes except to starknet. So as a temporary solution it returns 0x1 if the connection is successful with the starknet RPC and if not it returns 0x0.

Kakarot methods

Starknet methods

feat: Move Kakarot address and class hash from constants to env

Feature Request

Describe the Feature Request

Load these values from .env instead

pub const KAKAROT_MAIN_CONTRACT_ADDRESS: &str =
    "0x566864dbc2ae76c2d12a8a5a334913d0806f85b7a4dccea87467c3ba3616e75";

pub const PROXY_ACCOUNT_CLASS_HASH: &str =
    "0x0775033b738dfe34c48f43a839c3d882ebe521befb3447240f2d218f14816ef5";

Describe Preferred Solution

Use std::env::var("NAME")

Additional Context

This is useful as these parameters are expected to change often

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.