Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report: Events from multiple contracts not returned correctly #235

Open
3 tasks done
dishmop opened this issue May 27, 2022 · 0 comments
Open
3 tasks done

Bug report: Events from multiple contracts not returned correctly #235

dishmop opened this issue May 27, 2022 · 0 comments
Labels
C-bug Category: Something isn't working

Comments

@dishmop
Copy link

dishmop commented May 27, 2022

Prerequisites

Expected Behavior

When a contract calls another contract, we should be able to determine which emitted events come from which contract.

Current Behavior

Here is a transaction where one contract has called another (and maybe that called another one)- they all emit events.

Type this:
fetchd query tx --type hash EA8C0B4DF96C9E2A6D62F51FEFFFF9DFD23E25841E7D0CA23F180F85A58E7797

Look at the raw_log
Formatted in python with pprint we get:

[{'events': [{'attributes': [{'key': '_contract_address',
                              'value': 'fetch1k4x9c4qp5f2dtdrlxw2yk4ahksytw3tnpvcsg4zf6zftdukxt20q7lqgyd'},
                             {'key': '_contract_address',
                              'value': 'fetch1skemrn8c44vh8k5rag8rgfzus9w6ngptqpdyk4d2q3mg23mlljnq0nqmu2'},
                             {'key': '_contract_address',
                              'value': 'fetch1h3er28zy2pnrcc2vld4sk4wj2pjzu2tndyfy2apfp8cutr0cz5usggk36u'},
                             {'key': '_contract_address',
                              'value': 'fetch1skemrn8c44vh8k5rag8rgfzus9w6ngptqpdyk4d2q3mg23mlljnq0nqmu2'}],
              'type': 'execute'},
             {'attributes': [{'key': 'action',
                              'value': '/cosmwasm.wasm.v1.MsgExecuteContract'},
                             {'key': 'module', 'value': 'wasm'},
                             {'key': 'sender',
                              'value': 'fetch1kc07mf256cy244r4t3vxsth9gfcay8pxmgneap'}],
              'type': 'message'},
             {'attributes': [{'key': '_contract_address',
                              'value': 'fetch1k4x9c4qp5f2dtdrlxw2yk4ahksytw3tnpvcsg4zf6zftdukxt20q7lqgyd'},
                             {'key': 'token_id', 'value': 'token_id_2'},
                             {'key': '_contract_address',
                              'value': 'fetch1skemrn8c44vh8k5rag8rgfzus9w6ngptqpdyk4d2q3mg23mlljnq0nqmu2'},
                             {'key': 'action', 'value': 'transfer'},
                             {'key': 'token_id', 'value': 'token_id_2'},
                             {'key': 'amount', 'value': '1000000000000000000'},
                             {'key': 'to',
                              'value': 'fetch1fty4wekjea7ndy6auax70736hkyqvqf3h29thz'},
                             {'key': '_contract_address',
                              'value': 'fetch1h3er28zy2pnrcc2vld4sk4wj2pjzu2tndyfy2apfp8cutr0cz5usggk36u'},
                             {'key': 'action', 'value': 'update_asset'},
                             {'key': 'id', 'value': '2'},
                             {'key': 'borrower',
                              'value': 'fetch1fty4wekjea7ndy6auax70736hkyqvqf3h29thz'},
                             {'key': 'denomination', 'value': 'GBP'},
                             {'key': 'description', 'value': 'test asset01'},
                             {'key': 'fixed_fee', 'value': '0'},
                             {'key': 'fixed_recovery_costs', 'value': '0'},
                             {'key': 'guaranteed_recovery_ratio',
                              'value': '70'},
                             {'key': 'max_rate_bias', 'value': '0'},
                             {'key': 'max_recovery_time', 'value': '12'},
                             {'key': 'valuation_duration', 'value': '1'},
                             {'key': 'value', 'value': '100000'},
                             {'key': 'create_time', 'value': '1651835581'},
                             {'key': 'status', 'value': 'Secured'},
                             {'key': 'trustee',
                              'value': 'fetch1kc07mf256cy244r4t3vxsth9gfcay8pxmgneap'}],
              'type': 'wasm'}]}]

The event data is not split into seperate events - it is just a list of key-value pairs. At the moment, we are just seperating them by assuming that when there is a "_contract_address" key then this is the start of a new event...but is this valid? Can someone mess things up by emitting an event from a contract with a key _contract_address and spoof the indexer (for example) into thinking that the even has come from another contract?

To Reproduce

Se above

Context

Mac OS pointing at Dorado

Failure Logs

No response

@dishmop dishmop added the C-bug Category: Something isn't working label May 27, 2022
@ejfitzgerald ejfitzgerald added C-tracking Category: A tracking issue for groups of tasks and removed C-tracking Category: A tracking issue for groups of tasks labels Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants