Singleton State

A singleton state is a term used in Ethereum to refer to the current state of the entire blockchain. It is called "singleton" because there is only one instance of the state, which is maintained by all the nodes in the network. The state consists of all the accounts, contracts, and data stored on the blockchain at any given time. Whenever a new block is added to the blockchain, the state is updated to reflect the changes made by the transactions in the block.
When a new block is added to the Ethereum blockchain, it contains a set of transactions that modify the state of the blockchain. The state changes made by the transactions are then broadcasted to all nodes in the network, and each node updates its own copy of the singleton state to reflect the changes.
In Ethereum, the singleton state is represented by a data structure called the "state trie". The state trie is a Merkle tree data structure that stores the current state of all accounts and smart contracts on the blockchain. Each node in the state trie represents a unique account or contract, and its value contains the current state of that account or contract, such as its balance or storage data.
When a new block is added to the blockchain, the state trie is updated to reflect the changes made by the transactions in the block. Each node in the trie that is affected by a transaction is modified, and the resulting state trie is included in the block. When the block is broadcasted to the network, all nodes receive the updated state trie and use it to update their own copy of the singleton state.
Additional to this section:

Visual Representation

State Trie
+-----+
| Root|
+-----+
|
+---------+--------+
| |
+---+---+ +---+---+
| Acct1 | | Acct2 |
+---+---+ +---+---+
| |
+-------+-------+ +-------+-------+
| | | | | |
+---+---+ +---+---+ +---+---+ +---+---+
| Code | | Bal | | Code | | Bal |
+---+---+ +-----+ +---+---+ +-----+
| | |
+---+---+ +---+---+ +-----+
|Data 1 | |Data 2 | |Nonce|
+-------+ +-------+ +-----+
In this example, we have a simplified representation of the state trie in Ethereum, which consists of a single root node and two account nodes, Acct1 and Acct2. Each account node contains a set of properties, including a code hash, balance, storage data, and nonce.
The code hash represents the bytecode of the smart contract associated with the account. The balance represents the amount of Ether held in the account. The storage data represents any additional data associated with the account. The nonce is a number that is used to ensure the uniqueness of transactions associated with the account.
The state trie is a Merkle tree data structure, where each node is hashed based on the values of its children. This makes it possible to quickly verify the integrity of the state trie, and to efficiently propagate updates to the state trie across the network. The state trie is updated each time a new block is added to the blockchain, and the updates are broadcasted to all nodes in the network to ensure consistency and integrity.

How does propagation work?

The process of broadcasting the state updates to all nodes in the network after a new block is added to the Ethereum blockchain is known as "state propagation". The speed and efficiency of state propagation is an important factor in the overall performance and scalability of the network. State propagation in Ethereum is designed to be as fast and efficient as possible, while also maintaining the security and integrity of the network. When a node receives a new block, it first verifies that the block is valid and meets the consensus rules of the network. If the block is valid, the node begins propagating the block to other nodes in the network, along with the updated state trie.
State propagation in Ethereum is achieved through a process called "gossip protocol", where nodes randomly select other nodes in the network to share information with. Each node keeps track of a set of "peers" that it communicates with, and it periodically sends updates to those peers about the state of the blockchain. The gossip protocol is designed to be highly resilient and fault-tolerant, meaning that even if some nodes in the network go offline or become unavailable, the remaining nodes can continue to propagate state updates and maintain the integrity of the network.
Overall, while state propagation in Ethereum does require some time and resources, the protocol is designed to be as fast and efficient as possible, while also ensuring the security and integrity of the network. The speed and efficiency of state propagation will continue to be an important area of research and development as the Ethereum network and other blockchain systems evolve and grow in scale.

Visual Representation

Node A Node B
+----------------------+ +----------------------+
| | | |
| State Trie | | |
| (Block 10) | | |
| | | |
+----------+-----------+ +----------+-----------+
| |
+----------+-----------+ +----------+-----------+
| | | |
| New Block | | |
| (Block 11) | | |
| | | |
+----------+-----------+ +----------+-----------+
| |
+----------+-----------+ +----------+-----------+
| | | |
| Updated State Trie | | |
| (Block 11 data) | | |
| | | |
+----------+-----------+ +----------+-----------+
| |
+----------+-----------+ +----------+-----------+
| | | |
| State Trie Broadcast | | |
| | | |
+----------+-----------+ +----------+-----------+
| |
+----------+-----------+ +----------+-----------+
| | | |
| State Trie | | State Trie |
| (updated) | | (updated) |
| (Block 11 data) | | (Block 11 data) |
| | | |
+----------------------+ +----------------------+
In this example, we have two nodes in the Ethereum network, Node A and Node B. Node A has received a new block, Block 11, which contains a set of transactions that modify the state of the blockchain. Node A updates its own copy of the state trie to reflect the changes made by Block 11, and then broadcasts the updated state trie to Node B.
Node B receives the updated state trie from Node A and uses it to update its own copy of the singleton state. This ensures that both nodes have an up-to-date and consistent view of the state of the blockchain.
Overall, this example demonstrates the process of state propagation in Ethereum, where updated state information is broadcasted to all nodes in the network to ensure consistency and integrity. State propagation is a critical component of the Ethereum protocol, and is designed to be fast, efficient, and fault-tolerant.

Validation Process (See Merkle Tree)

When a node receives an updated state trie from another node, it must verify that the state trie is valid before using it to update its own copy of the singleton state.
In Ethereum, the state trie is a Merkle tree data structure, where each node in the tree is hashed based on the values of its children. This makes it possible to quickly verify the integrity of the state trie, by checking that the hashes of the nodes in the tree match the expected values.
When a node receives an updated state trie from another node, it first verifies the hash of the root node against the expected value. If the hash matches, the node can be confident that the state trie is valid and can be used to update its own copy of the singleton state. If the hash does not match, the node will reject the state trie and request a new one from another node.
In addition to verifying the integrity of the state trie, nodes in the network also perform other checks to ensure the validity of the transactions included in the block. This includes checking that the transactions are well-formed, that they are signed by the correct parties, and that they do not violate any of the consensus rules of the network.
Overall, while nodes in the network do not blindly accept state updates from other nodes, the verification process is designed to be fast and efficient, while also ensuring the security and integrity of the network.