Refactor to use plugeth-statediff #1

Merged
roysc merged 19 commits from refactor-use-plugin into v5 2023-09-28 04:04:01 +00:00
Showing only changes of commit 06fb10e209 - Show all commits

View File

@ -10,6 +10,7 @@ import (
"github.com/cerc-io/plugeth-statediff/indexer" "github.com/cerc-io/plugeth-statediff/indexer"
"github.com/cerc-io/plugeth-statediff/indexer/node" "github.com/cerc-io/plugeth-statediff/indexer/node"
"github.com/cerc-io/plugeth-statediff/indexer/shared" "github.com/cerc-io/plugeth-statediff/indexer/shared"
"github.com/cerc-io/plugeth-statediff/utils"
"github.com/cerc-io/plugeth-statediff/utils/log" "github.com/cerc-io/plugeth-statediff/utils/log"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
@ -89,28 +90,6 @@ func setupPreRunRanges() []pkg.RangeRequest {
return blockRanges return blockRanges
} }
// LoadConfig loads chain config from json file
func LoadConfig(chainConfigPath string) (*params.ChainConfig, error) {
file, err := os.Open(chainConfigPath)
if err != nil {
log.Error("Failed to read chain config file", "error", err)
return nil, err
}
defer file.Close()
chainConfig := new(params.ChainConfig)
if err := json.NewDecoder(file).Decode(chainConfig); err != nil {
log.Error("invalid chain config file", "error", err)
return nil, err
}
log.Debug(fmt.Sprintf("Using chain config from '%s'. Content: %+v", chainConfigPath, chainConfig))
return chainConfig, nil
}
func instantiateLevelDBReader() (pkg.Reader, *params.ChainConfig, node.Info) { func instantiateLevelDBReader() (pkg.Reader, *params.ChainConfig, node.Info) {
// load some necessary params // load some necessary params
logWithCommand.Debug("Loading statediff service parameters") logWithCommand.Debug("Loading statediff service parameters")
@ -134,7 +113,7 @@ func instantiateLevelDBReader() (pkg.Reader, *params.ChainConfig, node.Info) {
nodeInfo := getEthNodeInfo() nodeInfo := getEthNodeInfo()
chainConfigPath := viper.GetString("ethereum.chainConfig") chainConfigPath := viper.GetString("ethereum.chainConfig")
chainConf, err := LoadConfig(chainConfigPath) chainConf, err := utils.LoadConfig(chainConfigPath)
if err != nil { if err != nil {
logWithCommand.Fatalf("Unable to instantiate chain config: %s", err) logWithCommand.Fatalf("Unable to instantiate chain config: %s", err)
} }