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.
Related
I hope to have something like Block(5).hashdata. There is something like that in Solidity to get the hash data of another block?
Smart contracts have only access to the current EVM state. They cannot access the historical state. Thus, you cannot access the historical state in Solidity smart contracts.
This is because Ethereum nodes do not keep, or keep only limited historical state, stored on the disk unless you run specifical archive node.
Compared against a traditional program how much more does it cost to run an equivalent EVM smart contract ?
I'm looking for some rough estimate like: the same program would cost 100x more in EVM smart contract than on a traditional server.
well, when we talk about smart contract you only pay gas, so if you want to know how much it will cost to you, you need to know the gas price of your target chain and the gas of deploy the contract and call the functions you need to setup the contract, and only that, you don't have to pay any kind of bill for that, just the gas you spend
What would be an easy way to simulate a double spend on a locally running ethereum blockchain? Could ganache help with this? Could someone please point in the right direction? We are trying to build a monitoring tool to detect double spend but don't know how to create a double spend in the first place.
the idea of double spend is quite simple you have to get two or more nodes in pow sync and start mining then use one node to spend your ether after that stop it from broadcasting changes to the network and get it back to the older block before you spend your ether now resume mining but give the node more power so it can mine faster then the other your attacker blockchain will become the longest chain now you can resume broadcasting this will be challenging but you can use the miner Api https://github.com/ethereum/go-ethereum/wiki/Management-APIs provided with Geth to manipulate mining and blockchain process and transactions.
I'm developing a dapp and got it working well using web3 and testrpc.
My frontend is currently pretty "chatty" with contract calls (constant methods) and everything works super fast.
I was wondering what kind of latency I should expect in the real network for simple calls? do I need to aggresively optimize my contract reads?
It depends. If your dApp is running on a node (and is fully synced), then constant functions will execute similar to what you're seeing in your testing. If not, then all bets are off. Your latency will depend on the provider you're connecting to.
My best advice is once you finish development, deploy to testnet and run performance tests. Chances are if you're not running a fully synced local node, and your app is as chatty as you say, then you may be disappointed with the results. You would want to look into optimizing your reads, moving some state data out of the contract (is possible), or turning your client into a light node.
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.