1 为什么删了以后重启没办法挖矿,是因为创世块都被删了,你重新init一下就ok了。fullnode和lightnode工作原理很多不同。。,lightnode一般就是不挖矿的
你测试当然是都得测试。
2 怎么样整个区块的数据没办法恢复
只要让广播的区块无法通过验证就行了这样就硬分叉了,比如说 你试下篡改未来的区块,比如下一个挖到的块你把root改
,就会硬分叉。这个你有具体的日志信息?开个verbosity 5看下。还有一个点是 你是怎么篡改的
3 那如果改或者删除已经生成的数据呢?把大部分节点的Ldb都删掉,整个区块链的数据还是不会有影响吗? 我的篡改一般就是删除一些数据
这个真的不好说 因为如果你是把ldb文件打开删数据 因为本身是二进制文件,你随机删的话不知道删的是什么,。。一般是这样的话处理方法就是把数据库删掉重新init。你最好还是用专门的api来查数据库来针对性篡改比较好
4我是把源码一些api提取出来写的篡改脚本,一些现成的func可以直接用
4这个你要用的test.go话得把geth整个源码拷贝一份到你的GOROOT下。。。
package main
import (
"encoding/hex"
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/ethdb"
// "github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rlp"
)
func main() {
db, _ := ethdb.NewLDBDatabase("/Users/reimu/eth/chain/geth/chaindata", 128, 128)
defer db.Close()
fmt.Println(*db)
fmt.Println(db.Path())
testHash := common.HexToHash("1ff83e56e61474045300be48bfafa75f26b529f2b431ced50f9fb95179f552ef") // stateRoot from eth.getBlock()
StateDB, _ := state.New(testHash, db) // Result in a *StateDB
Addr := common.HexToAddress("67f1b0fde05a37ee895998e903e8242e63d036e0") // Contract Addr
// This key is the key of your target. It can be found by the result of ForEachStorage2()
key := common.Hash{
168, 196, 212, 195, 62, 53, 105, 154, 143, 63, 17, 71, 81, 9, 0, 148, 77, 246, 224, 215, 137, 180,