status-im / status-mobile

a free (libre) open source, mobile OS for Ethereum
https://status.app
Mozilla Public License 2.0
3.85k stars 984 forks source link

Expose ethereum logs details in an extension manipulable way #7075

Closed jeluard closed 5 years ago

jeluard commented 5 years ago

User Story

As a developer, I want to have an easy access to both data and logs property from logs events in an easy to consume way. It could be exposed in a new events property.

gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 120.0 DAI (120.0 USD @ $1.0/DAI) attached to it.

gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 2 months, 3 weeks from now. Please review their action plans below:

1) speedyfixer has been approved to start work.

Initial questions:

Could you provide some example of "easy to consume way"?

Learn more on the Gitcoin Issue Details page.

StatusSceptre commented 5 years ago

@speedyfixer you've been approved, @jeluard may be able to help with your initial question.

speedyFixer commented 5 years ago

Thanks @StatusSceptre , @jeluard could you help me with my initial question?

jeluard commented 5 years ago

@speedyFixer This is the place that should be enhanced: https://github.com/status-im/status-react/blob/develop/src/status_im/extensions/ethereum.cljs#L242 data and topics are available as hex. They should be decoded into clojure maps (that might require user to provide some hints).

GitHub
status-im/status-react
a free (libre) open source, mobile OS for Ethereum - status-im/status-react
speedyFixer commented 5 years ago

Thanks @jeluard , now, I'm reading status-react repo. I will keep you informed of my progress.

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

speedyFixer commented 5 years ago

Hi, I already read the status-react repo, I will back from holidays in two days.

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

speedyFixer commented 5 years ago

Hello, I'm back from holidays, today, I was coding some extensions and added it in Status App also I read almost all the documentation (Learning about status.im). I'm feel more confident with my knowledge about this great project :)

Tomorrow I will try to change data and log from hex to clojure maps and I will look up a way for testing it.

Note: Maybe I am not going to be quick because It's my first contact with this project, so if you need a quick fix please let me know to leave this issue. In the meantime I'm learning as fast as I can and I working hard to solve it quickly.

Regards

jeluard commented 5 years ago

@speedyFixer Great to hear that! Please take your time!

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

speedyFixer commented 5 years ago

Thanks @jeluard , I got stuck running status-react in my local environment (Ubuntu) but in the end I could run it. Now I can look the ethereum logs and test them. Could someone snooze the Gitcoin bot for a few days?

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

StatusSceptre commented 5 years ago

Snoozed @speedyFixer !

speedyFixer commented 5 years ago

Thanks @StatusSceptre , @jeluard I couldn't be able to make that re-frisk UI debugger works and seems like Figwheel hangs waiting for connects, is there any way to reach some that help me with it? Any Advice?

jeluard commented 5 years ago

@speedyFixer I am not using re-frisk. You can always do plain println style debugging.

jeluard commented 5 years ago

Actually for this task unit tests would probably be the simplest option.

speedyFixer commented 5 years ago

Thanks @jeluard , I was able to run re-frisk and Figwheel, so for any beginner dev with the same problem:

I was running status-react with a Real Android device but "figwheel-urls" in env/dev/env/config.cljs is set with 10.0.2.2 (Special alias to your host loopback interface, Host machine) so the problem was that figwheel was waiting for app connections that never happened because a wrong IP. Therefore, You can use a emulator with avd (10.0.2.2) or set the correct IP of real device in "figwheel-urls".

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

speedyFixer commented 5 years ago

Hi, now I am playing around with ethereum/logs event in extensions, I think that I will make a WIP PR on next Thursday or sooner if possible.

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

vs77bb commented 5 years ago

Hi @speedyFixer, any update on progress here?

speedyFixer commented 5 years ago

Hi @vs77bb , I will soon submit a PR, sorry for the delay, I had some problems with my computer.

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

speedyFixer commented 5 years ago

Hi, I think that ethereum/logs isn't working, I get 0 values with call it in custom extension, so I'm going to check this in order to solve this issue.

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

StatusSceptre commented 5 years ago

Thanks for the update @speedyFixer Snoozed the bot from pinging you for 5 days; let us know if we can help!

speedyFixer commented 5 years ago

Thank you so much @StatusSceptre !

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

jeluard commented 5 years ago

@speedyFixer Did you make progress on that one? i would be interested in using it :)

speedyFixer commented 5 years ago

Sorry @jeluard I'm stuck, I haven't achieved to find why the parse-log isn't getting called when I use ethereum/logs in a custom extension. I have made a lot of prints and also checking re-frisk UI and always I get 0 values, I have changed Network, contract and etc, but with no luck. Now I'm thinking how debug in advanced way with Cursive.

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

speedyFixer commented 5 years ago

Hello @jeluard and @StatusSceptre I found the bug with ethereum/logs, I going to raise a issue with the info and the possible fix.

speedyFixer commented 5 years ago

FYI #7344

StatusSceptre commented 5 years ago

Thanks @speedyFixer will make sure someone checks this out next week!

jeluard commented 5 years ago

@speedyFixer Sorry for those issues! Could you look at the logs parsing? Ultimately I think it would be easier to just rely on unit tests for this one. You don't really need to test it with a real extension.

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

speedyFixer commented 5 years ago

@jeluard Yes, I'm going to test it with unit tests.

speedyFixer commented 5 years ago

Hi @jeluard when you say: "that might require user to provide some hints" , do you refer to ABI contract interface? right? I will use "web3.eth.abi.decodeLog" for decode it and convert it to a Clojure map.

jeluard commented 5 years ago

Actually we have our own facility to decode ABI style hints (see the ns abi-spec). You can find some example of what I was thinking here e.g. :params ["address" "address" "uint256"] If you can, do not rely on anything provided by web3.

gitcoinbot commented 5 years ago

@speedyfixer Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

speedyFixer commented 5 years ago

I got it @jeluard thanks, I have some questions about hints providing by users, We can use params for decode data from logs, but We need "indexed" keyword for decode topics[n] where 0 < n < 4.

Reading the code I understood that if :type is provided by user then It's a indexed topic for encode purposes. https://github.com/status-im/status-react/blob/7985ee838ef2ae88d9c908f834c13d63bef7f546/src/status_im/extensions/ethereum.cljs#L304

For decode purposes, could I read hints about indexed arguments from user input?

e.g. In the next example the user doesn't provide :type and the LogBet has a indexed argument "player" of type address. Check Ropsten - Contract Events.

[ethereum/logs {:fromBlock "4479309"
                  :toBlock "4488087"
                  :address ["0x869CD9C7D178254cD6ACF448737D7Eed2CA7E839"]
                  :topics [[{:event "LogBet" :params ["address" "uint8" "int8" "uint256" "uint256" "bool"]}
                            {:event "drawBet" :params ["uint256" "uint8" "int8" "address" "uint256"]}]]
                  :on-success [store-result]}]

So, result has a Log that shows topic1: "0x000000000000000000000000cb0fa7f4600f5fa709353e741ebd3d37b8a9798a":

{:address 0x869cd9c7d178254cd6acf448737d7eed2ca7e839, :transactionHash 0xb5e09579c299066041e77bb9f56ea34952d5aab558a2727a34d0bf8d9707661e, :blockHash 0xe17dfafc8eddc898636a487a10a60ef257e434f88f58fdef947f3839d9e92e87, :transactionIndex 0x13, :topics [0x0a15cc8b657a0a07f2fdd9692b3c23013dd99170f303edd690ec8f67dfdb0a9b 0x000000000000000000000000cb0fa7f4600f5fa709353e741ebd3d37b8a9798a], :blockNumber 0x447b96, :logIndex 0x11, :removed false, :data 0x00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000017000000000000000000000000000000000000000000000000000000000000008400000000000000000000000000000000000000000000000000470de4df8200000000000000000000000000000000000000000000000000000000000000000000}

But I don't have the hint about type for topic1, so I couldn't decode it.

Could We change the user input for something like: (:indexed key added and It is optional):

[ethereum/logs {:fromBlock "4479309"
                  :toBlock "4488087"
                  :address ["0x869CD9C7D178254cD6ACF448737D7Eed2CA7E839"]
                  :topics [[{:event "LogBet" :params ["address" "uint8" "int8" "uint256" "uint256" "bool"] :indexed ["address"]}
                            {:event "drawBet" :params ["uint256" "uint8" "int8" "address" "uint256"]}]]
                  :on-success [store-result]}]

I have also been thinking about the key names in the Clojure map, key names could be:

  1. The same name in the contract (this must be provided by user in his input)
  2. arg1, arg2 and son on

What do you think about that options? Do you have any recommendation? If you prefer 1, could you give me an example of an user input?

Thanks in advance :+1: .