Closed h4nsu closed 4 months ago
I think even better would be to inspect the contract
field of the ContractEmitted
event and decode only ours. Inspect the definition of ContractEmitted
variant below. We don't even want to attempt decoding events from other contracts, because we could succeed by coincidence and return some incorrect event as a result.
@DamianStraszak Good idea, I drafted a PR with the fix you described
I think even better would be to inspect the
contract
field of theContractEmitted
event and decode only ours. Inspect the definition ofContractEmitted
variant below. We don't even want to attempt decoding events from other contracts, because we could succeed by coincidence and return some incorrect event as a result.
@DamianStraszak I agree, currently it has the false assumption all ContractEmitted
events in a block are related to one specific contract, which is of course not true. Checking if the events are emitted from that specific contract would be a good fix.
@h4nsu I'll take a look at the PR
Thanks!
As far as I understand the underlying code, it seems like
ContractExecutionReceipt.process_events()
filters all the events of typeContractEmitted
and attempts to decode them using contract's metadata. However, if "our" contract call resulted in some cross-contract calling and "their" contracts emitted their events, we won't be able to decode them (we have only "our" metadata, not theirs). Currently this results in unhandledscalecodec
exception and a crash. Maybe it's a good idea to put this part in a try-catch block?