I'm testing a private network and encountered weird problem. This situation may not be a problem and I felt weird because I'm newbie...
I setup 2 nodes.
Node 1: mining
Node 2: not mining but has a deployed contract
genesis block is:
{
"config": {
"chainId": <my id>,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"difficulty": "2000",
"gasLimit": "0xffffffff",
"alloc": {},
"nonce": "0x0000000000000042",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
Experiment 1: connect nodes
used admin.addPeer("enode of node 1")
This worked fine. and sync completed successfully.
Experiment 2: sending ether from node 1 to node 2
This worked fine.
gasPrice was 100000000000
Experiment 3: make a few contract transactions on node2 through web3
worked fine
Experiment 4: make a few more contract transactions on node 2 through web3
STOP WORKING
These uncompleted transactions were found in eth.pendingTransactions
First weird thing is exact same code suddenly stopped working.
My guess was gas price because gas price was increased to 500000000000.
Experiment 5: resend transaction with more gas
eth.resend = function (tx, gasPrice, gas) {
if (gasPrice) {
tx.gasPrice = gasPrice;
}
if (gas) {
tx.gas = gas;
}
tx.data = tx.input;
return eth.sendTransaction(tx);
};
eth.resend(eth.pendingTransactions[0], 500000000010)
but not worked.
That's why I start guessing this was because the transaction on node 2 is not broadcasted to node 1.
Experiment 6: I tried mining on node 2
When I started mining on node 2 by miner.start(1) command, these pending transactions were processed instantly.
I could even see the transaction both on node 1 and 2.
eth.getTransaction("0xdfecfcfb8e5b36071d6bfa562fc8b6bb859b72f140ccefd01473eb4554cf221b") on node 2
{
blockHash: "0x601f0eb7e97561dd012d1d4d59a8ba7952ff79252f94ac7273da57b2e5bfe0f6",
blockNumber: 950,
from: "0x487f5eea74ea5f3e94093d8b0501f1d2b0d5310a",
gas: 4712388,
gasPrice: 500000000000,
hash: "0xdfecfcfb8e5b36071d6bfa562fc8b6bb859b72f140ccefd01473eb4554cf221b",
input: "0x23b872dd00000000000000000000000044a70f237abc8d9fd8f8c536527481b4715c619b000000000000000000000000487f5eea74ea5f3e94093d8b0501f1d2b0d5310a00000000000000000000000000000000000000000000000000000000000003e8",
nonce: 1,
r: "0xe153a8fb9f68d0ab139e75eac798f9244c838931a43bc5f1ef966abeb372ed02",
s: "0x64ac48133c4bcf65e6c91a78fc244aaf4969eea8725a751522f9356dd1de5511",
to: "0x28e79f4f21ad1cc6d2ef3c3e040dd555f785e71c",
transactionIndex: 0,
v: "0x1b222",
value: 0
}
eth.getTransaction("0xdfecfcfb8e5b36071d6bfa562fc8b6bb859b72f140ccefd01473eb4554cf221b")
on node 1
{
blockHash: "0xa52322c50e82a7cafcf2ac0b76ba688e99809783498621714bcd7b8bd806a73d",
blockNumber: 640,
from: "0x487f5eea74ea5f3e94093d8b0501f1d2b0d5310a",
gas: 4712388,
gasPrice: 500000000000,
hash: "0xdfecfcfb8e5b36071d6bfa562fc8b6bb859b72f140ccefd01473eb4554cf221b",
input: "0x23b872dd00000000000000000000000044a70f237abc8d9fd8f8c536527481b4715c619b000000000000000000000000487f5eea74ea5f3e94093d8b0501f1d2b0d5310a00000000000000000000000000000000000000000000000000000000000003e8",
nonce: 1,
r: "0xe153a8fb9f68d0ab139e75eac798f9244c838931a43bc5f1ef966abeb372ed02",
s: "0x64ac48133c4bcf65e6c91a78fc244aaf4969eea8725a751522f9356dd1de5511",
to: "0x28e79f4f21ad1cc6d2ef3c3e040dd555f785e71c",
transactionIndex: 0,
v: "0x1b222",
value: 0
}
Looks fine at first but second weird thing is blockNumbers were different.
blockNumber on node 1 was 640. blockNumber on node 2 was 950.
Is this even possible?
Experiment 6: try to send ether from node 2 to node 1
The result was pending.
If I started mining on node2, transaction was processed but ether was never transferred.
By the way eth.blockNumber on node 1 was 901 and eth.blockNumber on node 2 was 974.
gasPrice of node 1 was 18000000000. gasPrice of node 2 was 500000000000.
So even blockNumber was not synced.
I checked transactions by eth.getTransaction command
eth.getTransaction("0xe51f5e0643819ceb7ceb20934f76c2db4786724814b5d474e0b33fa55061650e")
on node 2
{
blockHash: "0xe703703b7bb89c3c2dfb68ac9c7f26c6374c6aa1f0ecec392c630df16f96b9e0",
blockNumber: 949,
from: "0xc6f974025353e8badbef519ab6081691227285c5",
gas: 90000,
gasPrice: 18000000000,
hash: "0xe51f5e0643819ceb7ceb20934f76c2db4786724814b5d474e0b33fa55061650e",
input: "0x",
nonce: 3,
r: "0x57df9543232b4da2267b25c6e1e9c41bb1fc57d54e06bea865734ed4d9577bc6",
s: "0x1050806ea3c07989b8f43c358f5d0d98a75eabe6db0c86a5b6f1aaaf3b60e119",
to: "0xafce1a31f3573015b863e82e696d1734167bcce2",
transactionIndex: 0,
v: "0x1b221",
value: 30000000000000000000
}
eth.getTransaction("0xe51f5e0643819ceb7ceb20934f76c2db4786724814b5d474e0b33fa55061650e")
on node 1
{
blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
blockNumber: null,
from: "0xc6f974025353e8badbef519ab6081691227285c5",
gas: 90000,
gasPrice: 18000000000,
hash: "0xe51f5e0643819ceb7ceb20934f76c2db4786724814b5d474e0b33fa55061650e",
input: "0x",
nonce: 3,
r: "0x57df9543232b4da2267b25c6e1e9c41bb1fc57d54e06bea865734ed4d9577bc6",
s: "0x1050806ea3c07989b8f43c358f5d0d98a75eabe6db0c86a5b6f1aaaf3b60e119",
to: "0xafce1a31f3573015b863e82e696d1734167bcce2",
transactionIndex: 0,
v: "0x1b221",
value: 30000000000000000000
}
Somehow I was still able to find the transaction Id on both the nodes but this time blockNumber of node 1 was null.
Experiment 7: send ether from node 1 to node 2 again
This time ether did not transferred successfully.
The problem looked to be syncing because both the nodes were not syncing with each other at all.
Experiment 8: restart node 2 and addPeer() again
blockNumber was synced. even blockNumber of eth.getTransaction was modified.
My question is is this because of change of gas price or I should run multiple mining nodes?
Sorry for this disorganized questions.
Thanks in advance.