Make Transaction With Light Client Node
send ether from miner2 to light node
- miner2 console
> eth.getBalance("0x52ea0215068f436f837788686aa4b25de1a98f07")
0
> eth.sendTransaction({
"from": "c077f8420d5b6c125897d9c5e21293ff6f77855c",
"to": "52ea0215068f436f837788686aa4b25de1a98f07",
"gas": "30000",
"gasPrice": "9000",
"value": web3.toWei(10, "ether")
})
INFO [10-02|10:01:09] Submitted transaction fullhash=0x783316eb665a34620150c8789df0fb49295658ba9acd9f3c11420f251d2c49a4 recipient=0x52ea0215068f436f837788686aA4B25De1a98F07
"0x783316eb665a34620150c8789df0fb49295658ba9acd9f3c11420f251d2c49a4"
the unit of
gasLimit
andgasPrice
is Wei
And I can find the pending transaction information on miner2 node.
> txpool.status
{
pending: 1,
queued: 0
}
> eth.pendingTransactions
[{
blockHash: null,
blockNumber: null,
from: "0xc077f8420d5b6c125897d9c5e21293ff6f77855c",
gas: 30000,
gasPrice: 9000,
hash: "0x783316eb665a34620150c8789df0fb49295658ba9acd9f3c11420f251d2c49a4",
input: "0x",
nonce: 0,
r: "0x8b00a5aed1c998a730805910a73a8e8620e3b4d84e97a960c70c90999f63fcf3",
s: "0x42730cffcf098b80539e8438b3b223ebd9e7049232a8de4db2aaf00c3dbba8ac",
to: "0x52ea0215068f436f837788686aa4b25de1a98f07",
transactionIndex: 0,
v: "0x1bc0e",
value: 10000000000000000000
}]
> eth.getTransaction("0x783316eb665a34620150c8789df0fb49295658ba9acd9f3c11420f251d2c49a4")
{
blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
blockNumber: null,
from: "0xc077f8420d5b6c125897d9c5e21293ff6f77855c",
gas: 30000,
gasPrice: 9000,
hash: "0x783316eb665a34620150c8789df0fb49295658ba9acd9f3c11420f251d2c49a4",
input: "0x",
nonce: 0,
r: "0x8b00a5aed1c998a730805910a73a8e8620e3b4d84e97a960c70c90999f63fcf3",
s: "0x42730cffcf098b80539e8438b3b223ebd9e7049232a8de4db2aaf00c3dbba8ac",
to: "0x52ea0215068f436f837788686aa4b25de1a98f07",
transactionIndex: 0,
v: "0x1bc0e",
value: 10000000000000000000
}
But other nodes (server and light) has no information with this transaction.
> txpool.status
{
pending: 0,
queued: 0
}
start miner
- miner2 console
> miner.start(1)
INFO [10-02|10:08:31] Transaction pool price threshold updated price=18000000000
INFO [10-02|10:08:31] Starting mining operation
null
> INFO [10-02|10:08:31] Commit new mining work number=12 txs=1 uncles=0 elapsed=749.405µs
INFO [10-02|10:08:31] Successfully sealed new block number=12 hash=fa64c9…353322
INFO [10-02|10:08:31] 🔨 mined potential block number=12 hash=fa64c9…353322
- server console
> miner.start()
INFO [10-02|10:07:55] Transaction pool price threshold updated price=18000000000
INFO [10-02|10:07:55] Starting mining operation
null
> INFO [10-02|10:07:55] Commit new mining work number=12 txs=0 uncles=0 elapsed=99.34µs
INFO [10-02|10:07:55] Signed recently, must wait for others
> INFO [10-02|10:08:31] Imported new chain segment blocks=1 txs=1 mgas=0.021 elapsed=1.290ms mgasps=16.271 number=12 hash=fa64c9…353322
- light console
> INFO [10-02|10:08:31] Block synchronisation started
INFO [10-02|10:08:31] Imported new block headers count=1 elapsed=3.454ms number=12 hash=fa64c9…353322 ignored=11
Now, all of 3 nodes have the transaction information in block number 12.
> eth.getBlock(12)
{
difficulty: 1,
extraData: "0xd883010700846765746887676f312e372e318664617277696e0000000000000010d098b5ca2d18b67ef1698d2549cc749712a64dbf01f024ec56d17db708abb72931c5713fc1fd11c04ef3f7872b24c4819e17a986b3276d4b1de29524ce1fd101",
gasLimit: 4712388,
gasUsed: 21000,
hash: "0xfa64c9e050dc5e04566caf0dc85c3584408c0f4d7ebc1b0fbb841fd3ff353322",
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
miner: "0x0000000000000000000000000000000000000000",
mixHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
nonce: "0x0000000000000000",
number: 12,
parentHash: "0xfbfe67cd638d21f528036130cc703be8f8fdccb934d871f3f8c2eccda1ed4bf5",
receiptsRoot: "0x0e97b2e59ee972041bbec5a34a3eb0077800273d2573de56d9b9d4bd03b552b8",
sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
size: 719,
stateRoot: "0xe94a522f73f3ab4997f52e6252cb581d997512db90aa1e558810afff0535e616",
timestamp: 1506910111,
totalDifficulty: 14,
transactions: ["0x783316eb665a34620150c8789df0fb49295658ba9acd9f3c11420f251d2c49a4"],
transactionsRoot: "0xf2f38a110554d414dd7ace1635ef80d17f02ed05bc0cf415d1de6a5b9af4ac5b",
uncles: []
}
And I can find the updated transaction information by eth.getTransaction()
in server and miner2 node.
> eth.getTransaction("0x783316eb665a34620150c8789df0fb49295658ba9acd9f3c11420f251d2c49a4")
{
blockHash: "0xfa64c9e050dc5e04566caf0dc85c3584408c0f4d7ebc1b0fbb841fd3ff353322",
blockNumber: 12,
from: "0xc077f8420d5b6c125897d9c5e21293ff6f77855c",
gas: 30000,
gasPrice: 9000,
hash: "0x783316eb665a34620150c8789df0fb49295658ba9acd9f3c11420f251d2c49a4",
input: "0x",
nonce: 0,
r: "0x8b00a5aed1c998a730805910a73a8e8620e3b4d84e97a960c70c90999f63fcf3",
s: "0x42730cffcf098b80539e8438b3b223ebd9e7049232a8de4db2aaf00c3dbba8ac",
to: "0x52ea0215068f436f837788686aa4b25de1a98f07",
transactionIndex: 0,
v: "0x1bc0e",
value: 10000000000000000000
}
But light node still can not find it.
> eth.getTransaction("0x783316eb665a34620150c8789df0fb49295658ba9acd9f3c11420f251d2c49a4")
null
check balance
Light node has 10000000000000000000 Wei, it is 10 ether.
> eth.getBalance("0x52ea0215068f436f837788686aa4b25de1a98f07")
10000000000000000000
send ether from light to server node
- light node console
> eth.sendTransaction({
"from": "0x52ea0215068f436f837788686aa4b25de1a98f07",
"to": "0x726794b16f6c5b0be0b78d7713a876ed3da8be1a",
"gas": "30000",
"value": web3.toWei(0.630622, "ether")
})
INFO [10-02|14:18:05] Submitted transaction fullhash=0x3de2948bfbfdce732eb9498187611f20a37ca04fef811bfc73aaff951d40f0f0 recipient=0x726794b16F6c5B0Be0B78D7713a876eD3DA8BE1a
"0x3de2948bfbfdce732eb9498187611f20a37ca04fef811bfc73aaff951d40f0f0"
> txpool.status
{
pending: 1,
queued: 0
}
> eth.getTransaction("0x3de2948bfbfdce732eb9498187611f20a37ca04fef811bfc73aaff951d40f0f0")
{
blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
blockNumber: null,
from: "0x52ea0215068f436f837788686aa4b25de1a98f07",
gas: 30000,
gasPrice: 18000000000,
hash: "0x3de2948bfbfdce732eb9498187611f20a37ca04fef811bfc73aaff951d40f0f0",
input: "0x",
nonce: 3,
r: "0x48825e942ef3a6ceaff602ad9acfa2a612aab270e5d9a6d25713c7b8183b148",
s: "0x1ddcc03258dd3feceda2aa5ae181a9d08dc272ed4581303a6132cd29241392c9",
to: "0x726794b16f6c5b0be0b78d7713a876ed3da8be1a",
transactionIndex: 0,
v: "0x1bc0d",
value: 630622000000000000
}
Both server and miner2 nodes have pending of this transaction.
> txpool.status
{
pending: 1,
queued: 0
}
> eth.getTransaction("0x3de2948bfbfdce732eb9498187611f20a37ca04fef811bfc73aaff951d40f0f0")
{
blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
blockNumber: null,
from: "0x52ea0215068f436f837788686aa4b25de1a98f07",
gas: 30000,
gasPrice: 18000000000,
hash: "0x3de2948bfbfdce732eb9498187611f20a37ca04fef811bfc73aaff951d40f0f0",
input: "0x",
nonce: 3,
r: "0x48825e942ef3a6ceaff602ad9acfa2a612aab270e5d9a6d25713c7b8183b148",
s: "0x1ddcc03258dd3feceda2aa5ae181a9d08dc272ed4581303a6132cd29241392c9",
to: "0x726794b16f6c5b0be0b78d7713a876ed3da8be1a",
transactionIndex: 0,
v: "0x1bc0d",
value: 630622000000000000
}
start miner
- server node console
> eth.accounts
["0x726794b16f6c5b0be0b78d7713a876ed3da8be1a"]
> eth.getBalance("0x726794b16f6c5b0be0b78d7713a876ed3da8be1a")
369378000000000000
> miner.start()
INFO [10-02|14:21:04] Transaction pool price threshold updated price=18000000000
INFO [10-02|14:21:04] Starting mining operation
null
> INFO [10-02|14:21:04] Commit new mining work number=116 txs=1 uncles=0 elapsed=340.242µs
INFO [10-02|14:21:04] Signed recently, must wait for others
> txpool.status
{
pending: 1,
queued: 0
}
> eth.getTransaction("0x3de2948bfbfdce732eb9498187611f20a37ca04fef811bfc73aaff951d40f0f0")
{
blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
blockNumber: null,
from: "0x52ea0215068f436f837788686aa4b25de1a98f07",
gas: 30000,
gasPrice: 18000000000,
hash: "0x3de2948bfbfdce732eb9498187611f20a37ca04fef811bfc73aaff951d40f0f0",
input: "0x",
nonce: 3,
r: "0x48825e942ef3a6ceaff602ad9acfa2a612aab270e5d9a6d25713c7b8183b148",
s: "0x1ddcc03258dd3feceda2aa5ae181a9d08dc272ed4581303a6132cd29241392c9",
to: "0x726794b16f6c5b0be0b78d7713a876ed3da8be1a",
transactionIndex: 0,
v: "0x1bc0d",
value: 630622000000000000
}
// miner2 is start mining now
> INFO [10-02|14:21:47] Imported new chain segment blocks=1 txs=1 mgas=0.021 elapsed=773.433µs mgasps=27.152 number=116 hash=c5e48e…66832c
> txpool.status
{
pending: 0,
queued: 0
}
> eth.getTransaction("0x3de2948bfbfdce732eb9498187611f20a37ca04fef811bfc73aaff951d40f0f0")
{
blockHash: "0xc5e48edce1f6e62c1b931b5ffb03e483cad13f4a8b991ae2c0a05f40ae66832c",
blockNumber: 116,
from: "0x52ea0215068f436f837788686aa4b25de1a98f07",
gas: 30000,
gasPrice: 18000000000,
hash: "0x3de2948bfbfdce732eb9498187611f20a37ca04fef811bfc73aaff951d40f0f0",
input: "0x",
nonce: 3,
r: "0x48825e942ef3a6ceaff602ad9acfa2a612aab270e5d9a6d25713c7b8183b148",
s: "0x1ddcc03258dd3feceda2aa5ae181a9d08dc272ed4581303a6132cd29241392c9",
to: "0x726794b16f6c5b0be0b78d7713a876ed3da8be1a",
transactionIndex: 0,
v: "0x1bc0d",
value: 630622000000000000
}
> eth.getBlock(116)
{
difficulty: 1,
extraData: "0xd883010700846765746887676f312e372e318664617277696e000000000000002d16463729ee7500946094b5e01579de8d70a97fe0750d82c41dacbfffc8c1bb43db4cd94243c76e87b2e50cf385723352c3832591c26319f35d533d017b4e3c01",
gasLimit: 4712388,
gasUsed: 21000,
hash: "0xc5e48edce1f6e62c1b931b5ffb03e483cad13f4a8b991ae2c0a05f40ae66832c",
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
miner: "0x0000000000000000000000000000000000000000",
mixHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
nonce: "0x0000000000000000",
number: 116,
parentHash: "0xae31f1f52e5b66991df2aa873a9022c8347053f56797ba6c9ea7ba844f30e27f",
receiptsRoot: "0x928939382c4dbb70e2dc1319d3f6d5a92df4fd16ba7203da123ba10210b822a8",
sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
size: 722,
stateRoot: "0xafb96b419b28c1b90835bd28fa514c4a21349e55a1bccb4a48e65861e5fcd47b",
timestamp: 1506925307,
totalDifficulty: 118,
transactions: ["0x3de2948bfbfdce732eb9498187611f20a37ca04fef811bfc73aaff951d40f0f0"],
transactionsRoot: "0x60aa2c7eae6e31a7425261359d9d6c1989d995dd2310be0cc4756d7e68c47863",
uncles: []
}
- miner2 node console
> eth.getBalance("0x726794b16f6c5b0be0b78d7713a876ed3da8be1a")
369378000000000000
> eth.getBalance("0x52ea0215068f436f837788686aa4b25de1a98f07")
9629866000000000000
> miner.start()
INFO [10-02|14:21:47] Transaction pool price threshold updated price=18000000000
INFO [10-02|14:21:47] Starting mining operation
null
> INFO [10-02|14:21:47] Commit new mining work number=116 txs=1 uncles=0 elapsed=356.229µs
INFO [10-02|14:21:47] Successfully sealed new block number=116 hash=c5e48e…66832c
INFO [10-02|14:21:47] 🔨 mined potential block number=116 hash=c5e48e…66832c
> txpool.status
{
pending: 0,
queued: 0
}
> eth.getTransaction("0x3de2948bfbfdce732eb9498187611f20a37ca04fef811bfc73aaff951d40f0f0")
{
blockHash: "0xc5e48edce1f6e62c1b931b5ffb03e483cad13f4a8b991ae2c0a05f40ae66832c",
blockNumber: 116,
from: "0x52ea0215068f436f837788686aa4b25de1a98f07",
gas: 30000,
gasPrice: 18000000000,
hash: "0x3de2948bfbfdce732eb9498187611f20a37ca04fef811bfc73aaff951d40f0f0",
input: "0x",
nonce: 3,
r: "0x48825e942ef3a6ceaff602ad9acfa2a612aab270e5d9a6d25713c7b8183b148",
s: "0x1ddcc03258dd3feceda2aa5ae181a9d08dc272ed4581303a6132cd29241392c9",
to: "0x726794b16f6c5b0be0b78d7713a876ed3da8be1a",
transactionIndex: 0,
v: "0x1bc0d",
value: 630622000000000000
}
> eth.getBlock(116)
{
difficulty: 1,
extraData: "0xd883010700846765746887676f312e372e318664617277696e000000000000002d16463729ee7500946094b5e01579de8d70a97fe0750d82c41dacbfffc8c1bb43db4cd94243c76e87b2e50cf385723352c3832591c26319f35d533d017b4e3c01",
gasLimit: 4712388,
gasUsed: 21000,
hash: "0xc5e48edce1f6e62c1b931b5ffb03e483cad13f4a8b991ae2c0a05f40ae66832c",
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
miner: "0x0000000000000000000000000000000000000000",
mixHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
nonce: "0x0000000000000000",
number: 116,
parentHash: "0xae31f1f52e5b66991df2aa873a9022c8347053f56797ba6c9ea7ba844f30e27f",
receiptsRoot: "0x928939382c4dbb70e2dc1319d3f6d5a92df4fd16ba7203da123ba10210b822a8",
sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
size: 722,
stateRoot: "0xafb96b419b28c1b90835bd28fa514c4a21349e55a1bccb4a48e65861e5fcd47b",
timestamp: 1506925307,
totalDifficulty: 118,
transactions: ["0x3de2948bfbfdce732eb9498187611f20a37ca04fef811bfc73aaff951d40f0f0"],
transactionsRoot: "0x60aa2c7eae6e31a7425261359d9d6c1989d995dd2310be0cc4756d7e68c47863",
uncles: []
}
> eth.getBalance("0x726794b16f6c5b0be0b78d7713a876ed3da8be1a")
1000000000000000000
> eth.getBalance("0x52ea0215068f436f837788686aa4b25de1a98f07")
8998866000000000000
- light node console
> eth.accounts
["0x52ea0215068f436f837788686aa4b25de1a98f07"]
> eth.getBalance("0x52ea0215068f436f837788686aa4b25de1a98f07")
9629866000000000000
// miner2 is start mining now
> INFO [10-02|14:21:47] Imported new block headers count=1 elapsed=405.437µs number=116 hash=c5e48e…66832c ignored=0
> txpoolINFO [10-02|14:21:50] Imported new block headers count=1 elapsed=404.958µs number=117 hash=23963d…29390d ignored=0
> txpool.status
{
pending: 0,
queued: 0
}
> eth.getBlock(116)
{
difficulty: 1,
extraData: "0xd883010700846765746887676f312e372e318664617277696e000000000000002d16463729ee7500946094b5e01579de8d70a97fe0750d82c41dacbfffc8c1bb43db4cd94243c76e87b2e50cf385723352c3832591c26319f35d533d017b4e3c01",
gasLimit: 4712388,
gasUsed: 21000,
hash: "0xc5e48edce1f6e62c1b931b5ffb03e483cad13f4a8b991ae2c0a05f40ae66832c",
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
miner: "0x0000000000000000000000000000000000000000",
mixHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
nonce: "0x0000000000000000",
number: 116,
parentHash: "0xae31f1f52e5b66991df2aa873a9022c8347053f56797ba6c9ea7ba844f30e27f",
receiptsRoot: "0x928939382c4dbb70e2dc1319d3f6d5a92df4fd16ba7203da123ba10210b822a8",
sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
size: 722,
stateRoot: "0xafb96b419b28c1b90835bd28fa514c4a21349e55a1bccb4a48e65861e5fcd47b",
timestamp: 1506925307,
totalDifficulty: 118,
transactions: ["0x3de2948bfbfdce732eb9498187611f20a37ca04fef811bfc73aaff951d40f0f0"],
transactionsRoot: "0x60aa2c7eae6e31a7425261359d9d6c1989d995dd2310be0cc4756d7e68c47863",
uncles: []
}
pending issue at light node
If I specify the gasPrice
, but its value is less than minimum gas price, the transaction will always be pending on light node. And it also block the later transactions.
- light node console
> eth.sendTransaction({
"from": "0x52ea0215068f436f837788686aa4b25de1a98f07",
"to": "0x726794b16f6c5b0be0b78d7713a876ed3da8be1a",
"gas": "30000",
"gasPrice": "9000",
"value": web3.toWei(0.630622, "ether")
})
INFO [10-02|14:30:00] Submitted transaction fullhash=0x3999e0d6fe96aeb35f34fb98f3ecb06bf039a0885abd4c57fc10156bade95ac8 recipient=0x726794b16F6c5B0Be0B78D7713a876eD3DA8BE1a
"0x3999e0d6fe96aeb35f34fb98f3ecb06bf039a0885abd4c57fc10156bade95ac8"
> txpool.status
{
pending: 1,
queued: 0
}
- server and miner2 nodes console
> txpool.status
{
pending: 0,
queued: 0
}