brson · GitHub

What

Change the testutils functions Events::all and Logs::all to return Result.

Why

I am not sure this is the correct resolution, or if this is worth fixing at all.

These functions call Host::get_events, which returns Result. That function may return an error, in which case Events::all and Logs::all panic.

This patch avoids the panic, but doesn't necessarily improve the debugging experience, since calling these functions will still fail to retrieve useful event information.

Host::get_events calls Events::externalize, and that function may fail if any single event fails to serialize to XDR. It's not clear to me what the consequences of externalize failing are.

I have seen these functions fail after calling a contract while passing objects with invalid references (intentionally adversarial). Because those objects can't be visited by the host, serialization fails.

From a debugging standpoint, it would be more useful to return partial event lists, perhaps with the non-externalizable events replaced with a placeholder. But I also see that these events are externalized by the Host::try_finish method, which seems to be a step in finalizing a transaction, though I don't understand how it's used.

Known limitations

These functions still fail to return any events if just one event can't be externalized.

Read the original on github.com ↗