Augur uses event logs to store data that never needs to be accessed on-contract, since it is about 10x cheaper than on-contract storage. However, I've noticed that retrieving event logs (e.g., using eth_getLogs
) takes significantly longer than retrieval of on-contract data. (I know filters let you listen for new event logs, but I'm specifically concerned with looking up old event logs.)
I don't really understand how event logging works under the hood. Currently, we're indexing one (or more) of the log's arguments, then using eth_getLogs
to search on the indexed argument. For example, all Augur trades are logged and indexed by both market ID and account. Our UI looks up trades made by the current account as part of its initial loading. Right now this takes about 10 seconds to finish. The eth_getLogs
request is made asynchronously, and interleaved with the other initial market loading tasks, so it's not overly annoying at the moment. However I'm concerned about how this will scale as both Augur and the Ethereum blockchain as a whole grow.
My question: will retrieving event logs become prohibitively slow as the blockchain becomes larger? More specifically, what is the time complexity of eth_getLogs
? (Is blockchain size the relevant variable, or something else? Is eth_getLogs
even the correct RPC request for what I'm trying to do? Basically any insight into this problem is appreciated!)