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

Update process_transaction #680

Merged
merged 20 commits into from
Nov 14, 2018

Conversation

jseagrave21
Copy link
Contributor

@jseagrave21 jseagrave21 commented Oct 25, 2018

What current issue(s) does this address, or what feature is it adding?

-update-

  • Maintains parody with neo-cli RPC method
  • Ensures a tx sent via RPC is saved to the wallet

How did you solve this problem?
trial and error

How did you make sure your solution works?
unittest

Are there any special changes in the code that we should be aware of?
no

Please check the following, if applicable:

  • Did you add any tests?
  • Did you run make lint?
  • Did you run make test?
  • Are you making a PR to a feature branch or development rather than master?
  • Did you add an entry to CHANGELOG.rst? (if not, please do)

jseagrave21 and others added 14 commits October 9, 2018 20:38
Merge CoZ Development into jseagrave21 Development
Merge CoZ Development into jseagrave21 Development
Merge CoZ Development into jseagrave21 Development
* Update ExtendedJsonRpcApi.py

- add fix provided by @localhuman so original methods are returned as well as extended methods
…yOfZion#661)

* Add the option -u (unittest-net) to prompt.py

* Add unittest guildeline and add the smart contract source codes (UnitTest-SM.zip) to the fixtures package
for compatibility
* Fix ExtendedJsonRpcApi (CityOfZion#662)

* Update ExtendedJsonRpcApi.py

- add fix provided by @localhuman so original methods are returned as well as extended methods

* Mute expected test stacktrace and clearly identify why an exception is thrown. (CityOfZion#663)

* Add guideline for adding tests to the neo-privnet-unittest image (CityOfZion#661)

* Add the option -u (unittest-net) to prompt.py

* Add unittest guildeline and add the smart contract source codes (UnitTest-SM.zip) to the fixtures package

* Add raw transaction building examples (CityOfZion#665)

* Update neo-boa version to fix core building test
Merge CoZ Development into jseagrave21 Development
Merge CoZ Development into jseagrave21 Development
- add logic in case the tx is not relayed
- Add test in case tx fails to relay
@coveralls
Copy link

coveralls commented Oct 25, 2018

Coverage Status

Coverage increased (+0.0009%) to 83.745% when pulling 085f040 on jseagrave21:update-process_transaction into b7ae417 on CityOfZion:development.

Copy link
Member

@ixje ixje left a comment

Choose a reason for hiding this comment

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

I will leave the PR open for now so you can decide if you want to suggest the change to the C# project. If you do so and once it's accepted we can merge this. If you choose not to, then we'll have to close this. Please let me know your intentions

self.wallet.SaveTransaction(tx)
return tx.ToJson()
else:
raise JsonRpcError(-32001, "Could not relay tx %s " % tx.Hash.ToString())
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately accepting this change would make the behaviour of calls like sendtoaddress deviate from the C# implementation, which is not what we want. See:
/~https://github.com/neo-project/neo/blob/dbe688b7b1d64975128b8aefb5c3ee692df07cd5/neo/Network/RPC/RpcServer.cs#L525-L532

@jseagrave21
Copy link
Contributor Author

jseagrave21 commented Oct 25, 2018

@ixje I will try to suggest the change to C# but I may fail because I don't know C#. Perhaps a good compromise would be to just include self.wallet.SaveTransaction(tx) because this was missing from the original implementation and present in neo-cli /~https://github.com/neo-project/neo/blob/dbe688b7b1d64975128b8aefb5c3ee692df07cd5/neo/Network/RPC/RpcServer.cs#L528

@jseagrave21
Copy link
Contributor Author

jseagrave21 commented Oct 26, 2018

@ixje I looked at the neo-project RPC and I just don't feel comfortable tinkering since I am not set up to test the code and I don't really know how to code in C#. I still think that this line /~https://github.com/CityOfZion/neo-python/pull/680/files#diff-f9e9d3e0fbf0fb287940a8d009a379b2R560 is equivalent to this line /~https://github.com/neo-project/neo/blob/dbe688b7b1d64975128b8aefb5c3ee692df07cd5/neo/Network/RPC/RpcServer.cs#L528 and should be added. I would be happy to eliminate the additonal logic in case the tx fails to relay. What do you think?

@jseagrave21
Copy link
Contributor Author

jseagrave21 commented Oct 29, 2018

@ixje Based on my reading of the purpose of self.wallet.SaveTransaction(tx) here

def SaveTransaction(self, tx):
"""
This method is used to after a transaction has been made by this wallet. It updates the states of the coins
In the wallet to reflect the new balance, but the coins remain in a ``CoinState.UNCONFIRMED`` state until
The transaction has been processed by the network.
The results of these updates can be used by overriding the ``OnSaveTransaction`` method, and, for example
persisting the results to a database.

I really think we should at least add this line.

@ixje
Copy link
Member

ixje commented Nov 5, 2018

Sounds reasonable. I hope @localhuman can shed a quick light here because I'm far from familiar with that part of the neo-python code and I think he can probably do that in a minute or so

@jseagrave21
Copy link
Contributor Author

Based on our discussion, I will update the PR accordingly.

- revert original changes but maintain parody with neo-cli and include `self.wallet.SaveTransaction(tx)` to ensure the tx is saved to the wallet
- see /~https://github.com/neo-project/neo/blob/dbe688b7b1d64975128b8aefb5c3ee692df07cd5/neo/Network/RPC/RpcServer.cs#L528
- remove test for failure to relay
for compatibility
Merge neo-python development into jseagrave21 update-process_transaction
@jseagrave21
Copy link
Contributor Author

Okay @localhuman this is ready for your review. A brief recap: Originally, this PR was to bring the RPC method to parody with process_transaction from Send.py. However, this would take the RPC method out of parody with neo-cli. So, I have just updated process_transaction enough to bring it to parody with the neo-cli RPC method. Also, I believe this is an important piece of code to include for anyone who is sending tx via RPC. cc @ixje

@ixje
Copy link
Member

ixje commented Nov 14, 2018

👍

@ixje ixje merged commit 82afc0f into CityOfZion:development Nov 14, 2018
@jseagrave21 jseagrave21 deleted the update-process_transaction branch November 14, 2018 15:45
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.

4 participants