3

This question already has an answer here:

I have a few problems understanding the software architecture of the Blockchain. For me Blockchain is the database where all transactions, receipts, balances, etc are stored. But how is the connection to the EVM? Is the EVM responsible for changing the Blockchain database? When a full node receives a transaction or a new block. It processes the transactions with the EVM. Is the internal storage of the EVM the Blockchain or what is the internal storage of the EVM? When it is not the Blockchain, is the EVM only responsible for processing the transaction and sending a receipt back to the blockchain so it can do an update? Are there two instances - the blockchain (database) and the evm (processor)- or one instance the evm which includes the blockchain database? I hope you know what I am trying to say here.

marked as duplicate by Achala Dissanayake, Nicolas Massart, Raghav Sood, flygoing, Vignesh Karthikeyan Aug 9 '18 at 14:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4

A blockchain is an example of a more general concept, called a distributed state machine.

A state machine is a system that has a set of states, and a function that transistions between those states.

In a Ethereum, the state is the tree of account states, and the transition function takes a block as input, runs all of the transactions in the block on the EVM, and transitions to the new state resulting from the EVM execution.

So you can think of the EVM as part of the transition function between blocks.

2

Thomas's answer is very helpful.

In case it helps, it might be useful to think of the blockchain as similar to a database replay log that all nodes agree on thanks to consensus. The EVM is the protocol that governs the interpretation of the transactions contained in the log.

The protocol is sufficient in scope to enable embedding contracts in specially crafted transactions. The contracts are written in a simple machine code (bytecode) and the protocol covers how to interpret them. So, the transaction history chronicles the deployment of executable code.

The language of the contracts includes internal storage, so some inputs can trigger functions that change persistent values.

Given a sufficiently descriptive protocol, and given a set of transactions believed to be true (consensus is another topic), each properly functioning node can reach its own conclusions about the state that must be the case.

I think it's reasonable to summarize by saying that the data "lives" in the inputs. The blockchain itself is a system that convinces all nodes they have the valid, true history of the inputs, and that's all they need to know.

Hope it helps.

1

Is the EVM responsible for changing the Blockchain database?

Prior to a transaction, the "blockchain" represents a certain state. During the transaction, the state changes from pre-transaction to post-transaction (unless there's a reversion). That 'change from one state to another' is accomplished by the EVM. Some changes simply send Wei from one account to another. Others are more complicated, running a smart contract to change storage values. (Although some may quibble that a simple send does not require the EVM, the effect is the same.)

When a full node receives a transaction or a new block it processes the transactions with the EVM. Is the internal storage of the EVM the Blockchain or what is the internal storage of the EVM?

Distinguish between the EVM (which accomplishes the state change) to the state itself which is the current value of all the data in the database (or as most people would call it -- the current values of all the data on the chain).

When it is not the blockchain, is the EVM only responsible for processing the transaction and sending a receipt back to the blockchain so it can do an update?

I think you're getting hung up on the word. The blockchain can be thought of as a data structure where the blocks are chained together by including a reference (the parent hash) in the current block. I think of that data structure as the blockchain, but I also (at the same time) think of the whole thing as the blockchain. So, it's a many-faceted word. Perhaps best to think of it as the data structure. The EVM processes the state changes and stores the state changes in a chained together list of blocks.

Are there two instances - the blockchain (database) and the evm (processor)- or one instance the evm which includes the blockchain database?

See the previous answer.

Not the answer you're looking for? Browse other questions tagged or ask your own question.