eth-statediff-compliance/pkg/main.go

50 lines
983 B
Go
Raw Normal View History

package compliance
import (
"fmt"
"os"
"github.com/cerc-io/eth-testing/chaindata/mainnet"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
)
var (
chain *core.BlockChain
blocks []*types.Block
)
func loadChain() {
db := rawdb.NewMemoryDatabase()
core.DefaultGenesisBlock().MustCommit(db)
blocks = mainnet.GetBlocks()
chain, _ = core.NewBlockChain(db, nil, nil, nil, ethash.NewFaker(), vm.Config{}, nil, nil)
_, err := chain.InsertChain(blocks[1:])
if err != nil {
panic(err)
}
}
func Main() {
if len(os.Args) < 2 {
fmt.Println("usage: dumpdiff <outputdir>")
os.Exit(1)
}
outputDir := os.Args[1]
_, err := os.Stat(outputDir)
if os.IsNotExist(err) {
err = os.MkdirAll(outputDir, 0755)
}
if err != nil {
panic(err)
}
loadChain()
WriteDiffs(outputDir, chain, blocks)
}