Recently, I studied about EVM storage and LevelDB as a state database. And here's my question. I'm confused about relationship between levelDB and EVM storage. When a transaction that activates a specific smart contract is generated, the EVM uses the CA's codeHash value to find the corresponding contract in levelDB and does the state variable information of the contract enter the storage of the EVM?? And when the transaction ends, is the storage of EVM updated again with the contract information of the new transaction?? If so, what does it mean to say that EVM storage are persistent? Can anyone tell me what happens in levelDB and EVM storage when a transaction that changes the smart contract's state variable occurs?
LevelDB is a key-value database. It is an implementation detail of the go-ethereum client.
The "Ethereum World State" (EWS) for each address has its balance, nonce, bytecode's hash, storage's root. Geth uses LevelDB to store the EWS.
When a contract is executed it uses the bytecode hash to load the contract, and the storage's root to load the contract storage.
If the execution has completed successfully the entry of the contract in EWS is updated with new storage's root.