Is part of the miner work to schedulle some smart contract executions?

Viewed 35

I'm just trying to start to learn about ethereum and smart contracts and I'm understanding that the execution of an smart contract happens during the process of a transaction block's validation. Am I right about it?

If so, how is executed smart contracts that have an expiration date or some sort of execution that have to happen in the future? Is part of the miner work to schedulle some smart contracts executions?

1 Answers

the execution of an smart contract happens during the process of a transaction block's validation

As well as during the block mining. But yes, PoW validators run the transaction too - only this time with params (such as block.timestamp) of the block being validated to check if they get the same result (in this context state changes - storage, events, ...) as the miner.


Example:

function foo() public {
    require(block.timestamp == 1650000000);
}
  1. A miner produces a block with timestamp 1650000000, includes a transaction that successfully executes the foo() function.
  2. A validator validates this block at time 1650000001 but executes it in their EVM with simulated time 1650000000, and the transaction succeeds on their end as well.
Related