Files
brave-core/third_party
Christian Mazakas 415eb73139 [Polkadot] [Wallet] add extrinsic events parsing routines (#34766)
Resolves brave/brave-browser#53707

To properly grab the status of a submitted extrinsic in Polkadot, we must slowly
walk the chain within the given mortality window. Once an extrinsic has been
located in the extrinsics array of a given block, we can use this index to probe
the block's events for the extrinsic's status.

This PR adds the parsing layer of this equation, constructing a search needle
for the actual fee paid by the sender and then seraching for the status of the
extrinsic itself. Note that even failed extrinsics still incur fee penalties.

We depend on the memchr crate because events can be tens of KB and finding a
substring can then be a non-trivial operation. We start searching from the right
because that's typically where our submitted extrinsics tend to live.

Typically, we could use events.window(needle.len()).position(|window| window ==
needle) to probe for our search string but rustc is insistent in lowering byte
slice comparisons into a call bcmp, which would mean that if we slid the window
over the entire string, there could easily be something like 40,000 call bcmps.
The memchr crate seemed appropriate for this reason, as it's dramatically more
performant.
2026-04-14 10:15:40 -07:00
..