1

I am new to Ethereum and smart contracts. I understand ethereum is modeled as a state machine and smart contracts work as "agents" to change the state through transactions. However, it seems rather impossible for a miner to verify the smart contract output unless he understands the logic encoded in smart contract.

Consider following examples

  1. A smart contract that transfers the vehicle ownership from A to B. The local account runs this contract with enough gas and input as car registration number, from and to as data ( arguments ) to smart contract. What does miner verifies here? He / She doesn't have access to government vehicle registration database.

  2. A smart contract calls 2 or 3 other contracts and depending upon the output from these contracts, determines the next steps say make a reservation. How miner is going to verify this output?

Please let me know.

Thanks.

2 Answers2

1

it seems rather impossible for a miner to verify the smart contract output unless he understands the logic encoded in smart contract.

Miners do understand the logic encoded in the smart contracts. The compiled form is initially part of a deployment transaction signed by an externally owned account, then the bytecode becomes part of the chain where everyone can see it.

Informally, "Alice said 'deploy a contract with this bytecode, 0x123...'", therefor, 0x123... is "code" and the protocol gave it an address - the address of Alice's smart contract.

What does miner verifies here? He / She doesn't have access to government vehicle registration database.

This is a business logic question. Perhaps the contract deals with matters one step at a time. It could first record that a seller wants to sell a certain car. It could then wait for a signature from a registry following an Oracle pattern. This would represent something important in the business process, i.e. the "authorized" participant has signed off on something important. This is something all nodes can and will verify by checking how the contract reacts to that input.

A smart contract calls 2 or 3 other contracts and depending upon the output from these contracts, determines the next steps say make a reservation. How miner is going to verify this output?

As long as enough gas is supplied, it makes no difference how many contracts are involved in a chain of interactions. They can be thought of executing immediately regardless of complexity. The whole thing is deterministic and is processed in one "gulp". All or nothing. Only the original transaction waits to be mined.

Hope it helps.

Rob Hitchens
  • 55,151
  • 11
  • 89
  • 145
  • Hi, Rob. I am confused about whether the miner can get reward from verify the transactions of the incoming block. If there is no reward, why miner choose to verify the transaction? – wei wang Dec 10 '20 at 01:06
  • The miner gets the reward for including the transaction in the block. It's gas burned * gas price. So, if txn 0x1234 is included and it burns x gas at y price, the miner gets xy ETH for including it. The miner isn't concerned with what the transaction does. It might succeed or fail, and each node will evaluate what, if anything, the transaction accomplishes. – Rob Hitchens Dec 10 '20 at 23:00
0

The verification here isn't to check anticipated output of a contract, but instead, to verify that the contract is deployed correctly, interacts as expected with the network and follows the rules of the ethereum protocol.

Vignesh Karthikeyan
  • 1,950
  • 1
  • 12
  • 40
  • Could you please elaborate what does that mean? Thanks. – user2051548 Jun 11 '18 at 20:52
  • Your assumption "for a miner to verify smart contract output", is of question. That is not what a miner's role of verification is. It verifies valid transactions. Invalid output could still be a valid transaction. If this helps, accepting the answer helps the community grow. – Vignesh Karthikeyan Jun 11 '18 at 21:00