以太链防篡改测试

只要是测试如果已经生成的链我们对他进行篡改以后,是否会对后续的链的生成产生影响
首先我们新建立一个节点、连接到我们的私链
经过测试,我们开始连接的第三个节点在data/02目录下的节点貌似已经连接不上私链了,测试他连接的节点时有一些莫名其妙的信息出现

> admin.peers
[{
    caps: ["eth/63"],
    id: "3d8473147ee9fb11f695a636abb1718d04933218928e36c0f42d67f3211774e479f4cc8adeeb8684d1dfd87893ec5d88aac3debfd134585fc3973e11e912a93c",
    name: "Geth/v1.6.6-stable-10a45cb5/windows-386/go1.8.3",
    network: {
      localAddress: "192.168.0.4:34148",
      remoteAddress: "72.198.108.244:30303"
    },
    protocols: {
      eth: "handshake"
    }
}, {
    caps: ["eth/62", "eth/63", "par/1", "par/2"],
    id: "8aa57049d9469235914502e327b30df641a319ad26af36819d19f52d790a587989777807c46744dbcb67f20ae0dc4fe666178ee44d90be9fbccdf8ba501f9fb8",
    name: "Parity/v1.6.7-beta-e128418-20170518/x86_64-linux-gnu/rustc1.17.0",
    network: {
      localAddress: "192.168.0.4:58262",
      remoteAddress: "188.166.74.239:30303"
    },
    protocols: {
      eth: "handshake"
    }
}, {
    caps: ["eth/62", "eth/63"],
    id: "de4b3d3627e6c62aa6c1d591834510e6303d18a9ffd0b4f988a00cf32fd32790c187f82e015dc738de0cabde6a12d51f2d06b6f491e8ca0bf9d468527f171649",
    name: "Geth/v1.6.5-stable-cf87713d/linux-amd64/go1.8.3",
    network: {
      localAddress: "192.168.0.4:42754",
      remoteAddress: "158.69.90.185:30303"
    },
    protocols: {
      eth: "handshake"
    }
}]

所以我们在重新连接一个新的节点

初始化创始块
root@i-5tthrr8u:/home/ubuntu/private-geth# geth --datadir ./data/04 init ./genesis.json

进入geth控制台
geth --datadir ./data/04 --networkid 314590 --ipcdisable --port 611 --rpcport 8000 --bootnodes "enode://96f7a95a8c5e7a1f911142d87ce53ae882568be0435016e4803a6d410a9ecc7a69322cee8efbe8499ec7c737c377793182cab8869a076389c6b47626df00450b@192.168.0.4:61910" console

进去以后我们查看区块高度为0,但马上他就会同步更新区块的信息
> eth.blockNumber
0
> INFO [07-06|09:56:27] Block synchronisation started 
INFO [07-06|09:56:27] Imported new state entries               count=1 flushed=0 elapsed=108.966碌s processed=1 pending=4 retry=0 duplicate=0 unexpected=0
INFO [07-06|09:56:27] Imported new state entries               count=3 flushed=4 elapsed=104.056碌s processed=4 pending=0 retry=0 duplicate=0 unexpected=0
INFO [07-06|09:56:29] Imported new block headers               count=62 elapsed=1.959s    number=62 hash=11a7e5鈥7e1f8 ignored=0
INFO [07-06|09:56:29] Imported new chain segment               blocks=6 txs=0 mgas=0.000 elapsed=1.804ms   mgasps=0.000 number=6  hash=391702132d5
INFO [07-06|09:56:29] Imported new chain segment               blocks=56 txs=3 mgas=0.063 elapsed=19.885ms  mgasps=3.168 number=62 hash=11a7e5鈥7e1f8
INFO [07-06|09:56:29] Fast sync complete, auto disabling 

> 
> eth.blockNumber
62

接着我们修改该目录下的已经生成的区块信息

root@i-5tthrr8u:/home/ubuntu/private-geth/data/04/geth/chaindata# ll
total 252
drwxr-xr-x 2 root root   4096 Jul  6 09:55 ./
drwxr-xr-x 6 root root   4096 Jul  6 09:56 ../
-rw-r--r-- 1 root root    552 Jul  6 09:55 000002.ldb
-rw-r--r-- 1 root root 232585 Jul  6 09:56 000003.log
-rw-r--r-- 1 root root     16 Jul  6 09:55 CURRENT
-rw-r--r-- 1 root root      0 Jul  6 09:53 LOCK
-rw-r--r-- 1 root root    968 Jul  6 09:55 LOG
-rw-r--r-- 1 root root    235 Jul  6 09:55 MANIFEST-000004
root@i-5tthrr8u:/home/ubuntu/private-geth/data/04/geth/chaindata# vi 000002.ldb 





脛^H聽^@)^HH聽氓<80>脝v<9a>脙脻<80><89>K*%ad搂kyh9脪毛^?y<9e>枚鹿<85>^N楼猫.^A^C^@^@^@.^B^@0^Q LastBlock^A^G  ^Y~D^@(^D^N Header^A^H<96>1^@^L^@1^Cb   *^@^@<82>]^@^D^A^B      *X脛^H聽^@)^HH聽氓<80>脝v<9a>脙脻<80><89>K*%ad搂kyh9脪毛^?y<9e>枚鹿<85>^N楼猫.^A^C^@^@^@.^B^@0^Q LastBlock^A^G  ^Y~D^@(^D^N Header^A^H<96>1^@^L^@1^Cb   *^@^@<82>]^@^D^A^B      *XDereum-config-~<9c>^@^D^A               ?\{"chainId":15,"homestead^E茅P":0,"eip150Hash":"0x0煤^A^@^@"^MR^@5:b^@^@8^Q^P^P}^@^R h   <9d>^P^@^@n^A^
  L^@<88>聽^]脤M猫脼脟]z芦<85>碌g露脤脭^Z脫^RE^[<94><8a>t^S冒隆B媒@脭<93>G<94>^@J=^@<80>聽V猫^_^W^[脤U娄每<83>E忙<92>脌酶n[H脿^[<99>l颅脌^Ab/碌茫c麓!卯!^@    !^D鹿^AJx^@镁^A^@镁每每每每<80><80><80><82>脢^A^@<88>-^]^TB)   ^Dt^A->^AC^L^@1^Ar^M^\<82>_^B@^A^E^@^@^@^@^@^@脌^@^@^@^@^A^@^@^@^AH炉^C^Gp^Fl <87>^C脣<92>麓<8a>脫脮^F^@^@^@^@^M^@^@^@^K^@掳聽^]路/x^eldb.BuiltinBloomF^E^[(<8e>^C^V^@^@^@^@^A^@^@^@^A#g4+^W^T^@   ^Cs^A每  ^A(^@<89>^C^@^@^@^@^A^@^@^@^A貌脟{^T漏^C/脻^C^V^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^^@^@W没<80><8b>$uG

接着我们继续挖矿,发生交易,查看区块和交易的信息一切都是正常的。

 personal.unlockAccount(eth.accounts[0])
 > eth.sendTransaction({from: "0x28b769b3b9109afd1e9e50a9312c5a3bfae8a699", to: "0xb4e2e2514eae3684157bf34a0cee2c07c431cf92", gas:31000, 'gasPrice': web3.toWei(300, 'gwei'), "value": "1"})
INFO [07-06|10:02:50] Submitted transaction                    fullhash=0xe5bc604a9720b451207b690cc0da9858c4df2ba874f4516e83139992d26b04e4 recipient=0xb4e2e2514eae3684157bf34a0cee2c07c431cf92
"0xe5bc604a9720b451207b690cc0da9858c4df2ba874f4516e83139992d26b04e4"

> txpool.status
{
  pending: 1,
  queued: 0
}

> miner.start()

INFO [07-06|10:03:18] Updated mining threads                   threads=0
INFO [07-06|10:03:18] Transaction pool price threshold updated price=18000000000
nullINFO [07-06|10:03:18] Starting mining operation 
INFO [07-06|10:03:18] Commit new mining work                   number=69 txs=1 uncles=0 elapsed=632.178碌s

> INFO [07-06|10:03:24] Successfully sealed new block            number=69 hash=ebf2fc鈥d4fab
INFO [07-06|10:03:24] 馃敆 block reached canonical chain          number=64 hash=462502鈥bae73
INFO [07-06|10:03:24] 馃敤 mined potential block                  number=69 hash=ebf2fc鈥d4fab
INFO [07-06|10:03:24] Commit new mining work                   number=70 txs=0 uncles=0 elapsed=3.961ms
> miner.stop()
true

> txpool.status
{
  pending: 0,
  queued: 0
}

> eth.getBlock(68)

{
  difficulty: 202629,
  extraData: "0xd783010606846765746887676f312e382e31856c696e7578",
  gasLimit: 4018888180,
  gasUsed: 0,
  hash: "0x7cc550bdd21a01c816ac0eac6c5efa6ed4e6b23fea8db03ae84bd287a902ef54",
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  miner: "0x28b769b3b9109afd1e9e50a9312c5a3bfae8a699",
  mixHash: "0x3c156d47f33da7b2d2fe1bf3378c56b2c0f794e6d33df88d474cff51843a1025",
  nonce: "0x5fec81068a7a96e9",
  number: 68,
  parentHash: "0xd977b64e2954293d6d59c0ec7f45c43979a56053791d5b5808245fa8f5f0c54a",
  receiptsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
  sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  size: 536,
  stateRoot: "0xd0341d35ae2bbef5963dfdce8bc878b5b97e88c734560255842be448eed7ab14",
  timestamp: 1499306361,
  totalDifficulty: 15040450,
  transactions: [],
  transactionsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
  uncles: []
}

把该节点的ldb都删了

root@i-5tthrr8u:/home/ubuntu/private-geth/data/04/geth/chaindata# rm 000002.ldb 
root@i-5tthrr8u:/home/ubuntu/private-geth/data/04/geth/chaindata# ll
total 272
drwxr-xr-x 2 root root   4096 Jul  6 11:45 ./
drwxr-xr-x 6 root root   4096 Jul  6 09:56 ../
-rw-r--r-- 1 root root 254479 Jul  6 10:03 000003.log
-rw-r--r-- 1 root root     16 Jul  6 09:55 CURRENT
-rw-r--r-- 1 root root      0 Jul  6 09:53 LOCK
-rw-r--r-- 1 root root    968 Jul  6 09:55 LOG
-rw-r--r-- 1 root root    235 Jul  6 09:55 MANIFEST-000004

接下来我们启动节点,失败了,出乎意料。之前了解到的是分布式存储不存在单节点故障,所以应该是不影响其他节点的啊。因为我们所有的节点是在同一台机器的所以应该再一次测试在不同的主机节点的信息。

root@i-5tthrr8u:/home/ubuntu/private-geth# geth --datadir ./data/00 --networkid 314590 --ipcdisable --port 61910 --rpcport 8200 console
INFO [07-06|11:52:06] Starting peer-to-peer node               instance=Geth/v1.6.6-stable-10a45cb5/linux-amd64/go1.8.1
INFO [07-06|11:52:06] Allocated cache and file handles         database=/home/ubuntu/private-geth/data/00/geth/chaindata cache=128 handles=1024
Fatal: Error starting protocol stack: resource temporarily unavailable

接着我把整个节点都删除了又可以了

root@i-5tthrr8u:/home/ubuntu# cd private-geth/
root@i-5tthrr8u:/home/ubuntu/private-geth#  geth --datadir ./data/00 --networkid 314590 --ipcdisable --port 61910 --rpcport 8200 console
INFO [07-06|13:43:44] Starting peer-to-peer node               instance=Geth/v1.6.6-stable-10a45cb5/linux-amd64/go1.8.1
INFO [07-06|13:43:44] Allocated cache and file handles         database=/home/ubuntu/private-geth/data/00/geth/chaindata cache=128 handles=1024
INFO [07-06|13:43:44] Initialised chain configuration          config="{ChainID: 15 Homestead: 0 DAO: <nil> DAOSupport: false EIP150: <nil> EIP155: 0 EIP158: 0 Metropolis: <nil> Engine: unknown}"
INFO [07-06|13:43:44] Disk storage enabled for ethash caches   dir=/home/ubuntu/private-geth/data/00/geth/ethash count=3
INFO [07-06|13:43:44] Disk storage enabled for ethash DAGs     dir=/root/.ethash                                 count=2
INFO [07-06|13:43:44] Initialising Ethereum protocol           versions="[63 62]" network=314590
INFO [07-06|13:43:44] Loaded most recent local header          number=69 hash=ebf2fc鈥d4fab td=15240923
INFO [07-06|13:43:44] Loaded most recent local full block      number=69 hash=ebf2fc鈥d4fab td=15240923
INFO [07-06|13:43:44] Loaded most recent local fast block      number=69 hash=ebf2fc鈥d4fab td=15240923
WARN [07-06|13:43:44] Blockchain not empty, fast sync disabled 
INFO [07-06|13:43:44] Starting P2P networking 
INFO [07-06|13:43:47] UDP listener up                          self=enode://96f7a95a8c5e7a1f911142d87ce53ae882568be0435016e4803a6d410a9ecc7a69322cee8efbe8499ec7c737c377793182cab8869a076389c6b47626df00450b@[::]:61910
INFO [07-06|13:43:47] RLPx listener up                         self=enode://96f7a95a8c5e7a1f911142d87ce53ae882568be0435016e4803a6d410a9ecc7a69322cee8efbe8499ec7c737c377793182cab8869a076389c6b47626df00450b@[::]:61910
Welcome to the Geth JavaScript console!

instance: Geth/v1.6.6-stable-10a45cb5/linux-amd64/go1.8.1
coinbase: 0x28b769b3b9109afd1e9e50a9312c5a3bfae8a699
at block: 69 (Thu, 06 Jul 2017 10:03:18 CST)
 datadir: /home/ubuntu/private-geth/data/00
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> eth.blockNumber
69
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值