Compare commits

..

5 Commits

Author SHA1 Message Date
7b47871269 [wip] update mods 2023-08-25 20:57:02 +08:00
2708518798 docker updates
rm makefile
2023-08-25 20:57:02 +08:00
1003fe4eea update docs & config 2023-08-25 20:57:02 +08:00
e49839f859 replace prerun options with run command 2023-08-25 20:57:02 +08:00
b9cba4c605 refactor & use plugin builder
- removes StateTrieAt, we can no longer return a full trie without inner nodes
2023-08-25 20:33:35 +08:00
3 changed files with 34 additions and 14 deletions

View File

@ -156,10 +156,10 @@ func init() {
rootCmd.PersistentFlags().Bool("prom-db-stats", false, "enables prometheus db stats")
rootCmd.PersistentFlags().Bool("prom-metrics", false, "enable prometheus metrics")
rootCmd.PersistentFlags().Bool("prerun-include-block", true, "include block data in the statediff payload")
rootCmd.PersistentFlags().Bool("prerun-include-receipts", true, "include receipts in the statediff payload")
rootCmd.PersistentFlags().Bool("prerun-include-td", true, "include td in the statediff payload")
rootCmd.PersistentFlags().Bool("prerun-include-code", true, "include code and codehash mappings in statediff payload")
rootCmd.PersistentFlags().Bool("run-include-block", true, "include block data in the statediff payload")
rootCmd.PersistentFlags().Bool("run-include-receipts", true, "include receipts in the statediff payload")
rootCmd.PersistentFlags().Bool("run-include-td", true, "include td in the statediff payload")
rootCmd.PersistentFlags().Bool("run-include-code", true, "include code and codehash mappings in statediff payload")
viper.BindPFlag("server.httpPath", rootCmd.PersistentFlags().Lookup("http-path"))
viper.BindPFlag("server.ipcPath", rootCmd.PersistentFlags().Lookup("ipc-path"))
@ -208,10 +208,10 @@ func init() {
viper.BindPFlag("prom.dbStats", rootCmd.PersistentFlags().Lookup("prom-db-stats"))
viper.BindPFlag("prom.metrics", rootCmd.PersistentFlags().Lookup("prom-metrics"))
viper.BindPFlag("prerun.params.includeBlock", rootCmd.PersistentFlags().Lookup("prerun-include-block"))
viper.BindPFlag("prerun.params.includeReceipts", rootCmd.PersistentFlags().Lookup("prerun-include-receipts"))
viper.BindPFlag("prerun.params.includeTD", rootCmd.PersistentFlags().Lookup("prerun-include-td"))
viper.BindPFlag("prerun.params.includeCode", rootCmd.PersistentFlags().Lookup("prerun-include-code"))
viper.BindPFlag("run.params.includeBlock", rootCmd.PersistentFlags().Lookup("run-include-block"))
viper.BindPFlag("run.params.includeReceipts", rootCmd.PersistentFlags().Lookup("run-include-receipts"))
viper.BindPFlag("run.params.includeTD", rootCmd.PersistentFlags().Lookup("run-include-td"))
viper.BindPFlag("run.params.includeCode", rootCmd.PersistentFlags().Lookup("run-include-code"))
rand.Seed(time.Now().UnixNano())
}

View File

@ -43,14 +43,14 @@ var runCmd = &cobra.Command{
},
}
func init() {
rootCmd.AddCommand(runCmd)
}
func runRanges() {
service := createStateDiffService()
// start service and servers
var wg sync.WaitGroup
if err := service.Loop(&wg); err != nil {
logWithCommand.Fatalf("unable to start statediff service: %v", err)
}
ranges := getConfiguredRanges()
service.Run(ranges)

View File

@ -6,10 +6,8 @@ import (
"fmt"
"os"
gethsd "github.com/cerc-io/plugeth-statediff"
ind "github.com/cerc-io/plugeth-statediff/indexer"
"github.com/cerc-io/plugeth-statediff/utils/log"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/trie"
"github.com/spf13/viper"
@ -88,3 +86,25 @@ func createStateDiffService() *sd.Service {
}
return sd.NewStateDiffService(lvlDBReader, indexer, sdConf)
}
// LoadConfig loads chain config from json file
func LoadConfig(chainConfigPath string) (*params.ChainConfig, error) {
file, err := os.Open(chainConfigPath)
if err != nil {
log.Error(fmt.Sprintf("Failed to read chain config file: %v", err))
return nil, err
}
defer file.Close()
chainConfig := new(params.ChainConfig)
if err := json.NewDecoder(file).Decode(chainConfig); err != nil {
log.Error(fmt.Sprintf("invalid chain config file: %v", err))
return nil, err
}
log.Info(fmt.Sprintf("Using chain config from %s file. Content %+v", chainConfigPath, chainConfig))
return chainConfig, nil
}