Generating state pre-images with Erigon
Unlike some other clients, Erigon actually stores the plain-state (or pre-images of keys) of the state. The MPT root calculation takes places in a different stage of block execution/processing.
So, once an erigon node is synced, it's database can be used to generate and export a file containing these pre-images in a sorted order. This order will, thus, coincide with the order of keys in the MPT
APPROACH 1
While walking over all the entries in the table called PlainState, do:
If the key (which is also the account address) doesn't have any storage slots, push it to the ETL collector, as is, with {key: hash(acc), val: acc}
If the key has storage slots, push the storage slots of the account in the same ETL collector, each with {key: hash(acc) + hash(storage_slot_i), val: storage_slot_i}