Layer-2 Solidity interview: whatโs a sane event-logging + monitoring setup without bloating L1 data fees?
๐ Moderator Tip (Context & Framework):
> Architectural efficiency in smart contracts hinges on the cost asymmetry between
SSTORESLOADoperations and indexedLOGopcodes for off-chain indexing services (The Graph, subgraphs).> Gas Optimization Deep Dive: Review Section 2 of our Top 30 Senior Solidity Developer Guide
> Live Scenarios: Practice handling gas optimization interview prompts in the Smart Contract Interview Prep Hub
Yesterday I got asked something in interview that sounded simple but I realized I only had a โblog answerโ for it.
If youโre shipping Solidity on Layer-2s (Optimism / Arbitrum / zkSync), how do you design efficient logging and monitoring so you can debug incidents and prove what happened later โ without spamming events and quietly increasing user costs?
I know events are cheaper than storage, but the interviewer pushed on tradeoffs:
What do you log on-chain vs what do you rely on off-chain indexing (The Graph / subgraphs / custom indexers)?
Do you treat events like a stable โAPIโ (small schema, long-lived), or do teams log more aggressively on critical paths (withdrawals, upgrades, liquidations)?
How do you handle the cases where users say โmy tx failedโ โ because if it reverted, you donโt even get logs to read.
If youโve built production contracts, Iโd love a real answer: whatโs your default event schema mindset, what do you index, what do you alert on, and what would you avoid emitting even on L2?