Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

getNonce and addInvokeTransaction TxV1 on RPC v0.1 #303

Merged
merged 4 commits into from
Oct 12, 2022

Conversation

gregoryguillou
Copy link
Contributor

@gregoryguillou gregoryguillou commented Oct 9, 2022

Usage related changes

This PR enables starknet_getNonce and allow to collect and pass the Nonce from RPC v0.1 to the gateway. This also enables to execute an v1 transaction on RPC v0.1 by making entry_point_selector optional as expected by v1 from what I understand.

Development related changes

There are 3 changes associated with this PR:

  • implement get_nonce in RPC
  • convert nonce with hex in add_invoke_transaction to make it consistent with version or max_fee
  • make entry_point_selector optional on make_invoke_function in RPC and update add_invoke_transaction to also make it optional

Checklist:

  • Applied formatting - ./scripts/format.sh
  • No linter errors - ./scripts/lint.sh
  • Performed code self-review
  • Rebased to the last commit of the target branch (or merged it into my branch)
  • Documented the changes
  • Linked the issues which this PR resolves
  • Updated the tests
  • All tests are passing

I am sorry for the tests but I do not know how to handle it properly

@gregoryguillou gregoryguillou force-pushed the feature/get_nonce branch 2 times, most recently from c96a293 to abdb148 Compare October 9, 2022 13:30
@gregoryguillou
Copy link
Contributor Author

Hi,

I've tested the change with an integration test on Caigo and it works fine. I think it provides the ability to address #275 before we can migration to v0.2 of the protocol. This would provide the same level of feature than eqlabs/pathfinder#632.

I am sorry, I do not know how to write the associated tests

@gregoryguillou gregoryguillou marked this pull request as ready for review October 9, 2022 13:41
@gregoryguillou gregoryguillou changed the title attempt to execute Txn v1 with rpc 0.1 Allow getNonce and Tx V1 with addInvokeTransaction on RPC v0.1 Oct 9, 2022
@gregoryguillou gregoryguillou changed the title Allow getNonce and Tx V1 with addInvokeTransaction on RPC v0.1 getNonce and addInvokeTransaction TxV1 on RPC v0.1 Oct 9, 2022
@ivpavici
Copy link
Contributor

ivpavici commented Oct 10, 2022

Hi @gregoryguillou , thanks!
But we already have this PR open, can you check if changes are covered? I see it also implements get_nonce for example

@gregoryguillou
Copy link
Contributor Author

Hi @gregoryguillou , thanks! But we already have this PR open, can you check if changes are covered? I see it also implements get_nonce for example

I saw the PR and I am looking forward to having it on master 💯 ! Mine is way smaller and it has a different goal: just make V1 pass with the current RPC v0.1 implementation. I am guessing it depends on your timeframe! But rest assure, I would love to have V1 running with RPC on devnet! So if you plan to not deliver any release before #292, lets move towards that one. If you plan to have intermediary version, I would argue that mine could be applied in the meantime.

Copy link
Collaborator

@FabijanC FabijanC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the discussion and we will first merge your PR, @gregoryguillou. Can you first make sure that you formatted the code?

@gregoryguillou
Copy link
Contributor Author

I read the discussion and we will first merge your PR, @gregoryguillou. Can you first make sure that you formatted the code?

LGTM:

 ./scripts/format.sh
The currently activated Python version 3.10.6 is not supported by the project (>=3.8,<3.10).
Trying to find and use a compatible version.
Using python3.9 (3.9.14)
All done! ✨ 🍰 ✨
79 files left unchanged.

@FabijanC FabijanC self-requested a review October 11, 2022 12:13
Copy link
Collaborator

@FabijanC FabijanC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I unchecked a point in your checklist ("Documented the changes") since your PR introduces an implementation for method starknet_getNonce, but page/docs/guide/json-rpc-api.md was unchanged.

Regarding tests, you can take a look at test/rpc/test_rpc_transactions.py. Perhaps using pytest.mark.parametrize will be of use; you could modify some of the existing tests to add an extra case where entry_point_selector or nonce is omitted.

@gregoryguillou
Copy link
Contributor Author

  • 2 tests have been added:
    • (1) a call to starknet_getNonce
    • (2) a call to starknet_addInvokeTransaction with version set to 1, a nonce and no entry_point_selector
  • starknet_getNonce has been removed from the unsupported verbs in the documentation
  • I have run the test, re-run format.sh and reviewed the PR. @FabijanC , thank you for your help and directions. Let me know if you need I change other things.

test/rpc/test_rpc_misc.py Outdated Show resolved Hide resolved
@FabijanC FabijanC self-requested a review October 12, 2022 09:26
@FabijanC FabijanC merged commit a027fd6 into 0xSpaceShard:master Oct 12, 2022
@gregoryguillou gregoryguillou deleted the feature/get_nonce branch October 12, 2022 11:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants