Can Ethereum's Validator execute several Smart Contracts at the same time? Or it can not make any other operation if started the execution?
Since transactions from a block or pool are executed sequentially, and a transaction can only refer to one smart contract, the EVM executes only one smart contract at a time (while internal calls from it are possible).
А в чем собственно проблема? :-)
Related
I am really confused for now. I am working on Solidity DEV, but today, I try to think of one question, how many EVM is in the Ethereum chain?
I am not joking. I really want to know, when to create the EVM. I have read the doc https://ethereum.org/en/developers/docs/evm/. But still not clear about that question. So, I mean, whether we only have one EVM in the chain or each validation node(RPC node) has one EVM or when the metamask tries to make a transaction with the RPC node, the RPC node creates an EVM and loads the target smart contract or each metamask is an EVM. I am really confused now. Please help me, if you know the sure answer. Really really thanks.
EVM is smart contract runtime. Each ethereum node has Ethereum software and inside the software, it is running a virtual computer. EVM is a Turing-complete machine and since it runs on different nodes and you have no access to it, it is called a "virtual machine". It is a kinda cloud computing machine. the only thing this machine can do is execute smart contracts.
Metamask is just a wallet, a middleman. It passes your requests to Ethereum blockchain.
When running a private Ethereum network not requiring gas for transactions, can a contract function transaction fail for some "unpredictable" issue, other than explicit invocation of assert()/require()/revert(), for example dividing by 0 or some other issue with EVM or beyond EVM?
division by zero
integer overflow/underflow in Solidity 0.8+ (previous versions let the number overflow, 0.8 throws an exception)
accessing out-of-bounds array index
message call (aka internal transaction) to an address that does not implement the called function (might have been selfdestruct or changed implementation behind a proxy)
These I could think of right now. I'm sure there's more examples, generally runtime errors cause by some logical mistake.
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?
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);
}
A miner produces a block with timestamp 1650000000, includes a transaction that successfully executes the foo() function.
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.
I'm working on sending transactions from one address to another on the goerli testnet and all transactions so far are not confirming. They have been staying in a pending state: https://goerli.etherscan.io/tx/0x056187763bac9adc8696fa0554c26b2f0e8ac48601dd4e5f03a30536d6597bf0
Did I do something wrong? I see the transaction in the etherscan.io/tx, but do I need some sort of callback handler?
Is this because there are not enough miners on the goerli testnet? Is Kovan the best testnet for ethereum dapp/smart contract development where transactions are being confirmed more often?
Any help is appreciated.
The linked transaction offers gas price of 0.000000002 Gwei (which is 2 wei). Usual current gas price on the Goerli network is 2 Gwei (1 billion times larger).
So it just seems that your sending script incorrectly calculates the decimals for the gas price.
Most miners order transactions by the gas price. So if there were more miners or less pending transactions, there would be a higher probability of this transaction making it to the block. But in the current situation, you need to raise the gas price of your transaction in order to compete with the other pending transactions.
If you want to replace the gas price on this particular transaction, you can send a new one with the same nonce but higher gas fee.
I want to get all receipt records of some address (address A) from blockchain. I use web3.eth.getBlock and web3.eth.getTransaction to get all transactions related to A.
But I find if ethers are transfered to address A by invoking 'A.send' or 'A.transfer' function in contract, I can only get a contract call transaction which from caller address to contract address. And I can't find relationship between this transaction and address A.
Is there any way to get transactions invoked by contract for A?
Thanks.
Short answer: listen to events instead of monitoring transactions.
Why can't I find the transactions "invoked by" the contract?
A contract does not invoke/create its own transaction (it doesn't have a private key to sign one). A contract can call other contracts during its own execution, as you've seen, but those calls are all executed as part of the same transaction.
The recommended way to discover executed function calls is to use events. If the contract you want to watch does not specify an event on the call you want to watch, you may be in for some heavy lifting: tracing every transaction's execution at the EVM level (something that big block explorers do to generate some of the extra info they provide).
If you are stuck tracing: you can find more about using ethereumjs-vm or geth's debug_traceTransaction on this Ethereum StackExchange Question about internal transactions.