Skip to content

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

Open
@dishmop

Description

@dishmop

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions