1

Ref: What happens when you type in an URL in the browser

So in a web browser, it's kinda easy to reason the life cycle of an HTTP request, how it moves down the network stack, reach the server, get a response and travel back up to my browser and gets rendered as a web page.

var contractAbi = eth.contract(AbiOfContract);
var myContract = contractAbi.at(contractAddress);
// suppose you want to call a function named myFunction of myContract
var getData = myContract.myFunction.getData(function parameters);
//finally paas this data parameter to send Transaction
web3.eth.sendTransaction({to:Contractaddress, from:Accountaddress, data: getData});

What happens when I type the following code in a geth console of a 2 node private Ethereum network(1 full pair node, 1 mining node)? Let's say we are running a light client.

  1. The raw request(JSON RPC) would be sent to 1 of the 2 nodes or broadcast to both of the 2 node at the same time?
  2. How is the p2p module involved in the whole picture? Just maintain the alist of nodes in the entire 2-node network or just a subset?
  3. What happens when the raws request reach the first Ethereum node or second? Does it differ (first or sencond)?
  4. How is EVM work in the picture if I treat it as an blackbox? How the interface look like(input, output)?

EDIT 1: Let's assumming we are using POW. But since there is only one single mining node, POA is fine as well?

EDIT 2: In terms of performing the computation of the transaction(eg. 1+1), how do the mining node(say POA) and normal peer full node differ if they do differ?

EDIT 3: This articledid a great job at explaining on a higher level how a transaction get validated by all the nodes and only get "run" by the mining node, and after being included into the mining node, how a block get broadcasted and its transactions get further validated and propagated until the sender pickup the EVM logs. But how exactly EVM "crunch" the transactions and mutate the state? and how the p2p modules maintain all the nodes?

EDIT 4: this is another nice short read summarizing it as : construct->sign->broadcast->mine

enter image description here found this cool image here

1 Answer 1

4

You're missing the mining process. You should really explore it for a better understanding.

Transactions will be sent to one of the nodes which will broadcast the transaction to the other(s). Concurrency and order isn't important because although the transactions will eventually be known to all nodes, none of the nodes will do any transaction processing at this stage.

Someone will mine a block. It could be PoA, POW, something else. It doesn't matter as long as all/both nodes can agree on block validity. Eventually, not simultaneously, all nodes will be made aware of the new block.

Blocks are well-ordered sets of transactions. So, both nodes will eventually agree on a transaction order. By extension, the nodes will agree on the state at each block height.

Transactions are processed in the order they appear in the mined blocks.

Hope it helps.

2
  • So how do EVM "run" an transaction and when does it happen? during propagation or only happens when a miner node decides to include a tx into a block?
    – noooooooob
    Nov 13, 2018 at 9:33
  • Nodes run transactions when they appear in a block. Nov 13, 2018 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.