Use LoadConfig from ipld-eth-server
This commit is contained in:
parent
c468b494dc
commit
f4c1ca4ebe
@ -2,16 +2,14 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/params"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-db-validator/pkg/validator"
|
"github.com/vulcanize/ipld-eth-db-validator/pkg/validator"
|
||||||
|
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
||||||
)
|
)
|
||||||
|
|
||||||
// stateValidatorCmd represents the stateValidator command
|
// stateValidatorCmd represents the stateValidator command
|
||||||
@ -40,8 +38,7 @@ func stateValidator() {
|
|||||||
trail := viper.GetUint64("validate.trail")
|
trail := viper.GetUint64("validate.trail")
|
||||||
|
|
||||||
chainConfigPath := viper.GetString("ethereum.chainConfig")
|
chainConfigPath := viper.GetString("ethereum.chainConfig")
|
||||||
chainCfg, err := LoadConfig(chainConfigPath)
|
chainCfg, err := eth.LoadConfig(chainConfigPath)
|
||||||
fmt.Println("chainCfg", chainCfg)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logWithCommand.Fatal(err)
|
logWithCommand.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -62,12 +59,12 @@ func init() {
|
|||||||
stateValidatorCmd.PersistentFlags().String("block-height", "1", "block height to initiate state validation")
|
stateValidatorCmd.PersistentFlags().String("block-height", "1", "block height to initiate state validation")
|
||||||
stateValidatorCmd.PersistentFlags().String("trail", "0", "trail of block height to validate")
|
stateValidatorCmd.PersistentFlags().String("trail", "0", "trail of block height to validate")
|
||||||
|
|
||||||
stateValidatorCmd.PersistentFlags().String("chainConfig", "", "path to chain config")
|
stateValidatorCmd.PersistentFlags().String("chain-config", "", "path to chain config")
|
||||||
|
|
||||||
_ = viper.BindPFlag("validate.block-height", stateValidatorCmd.PersistentFlags().Lookup("block-height"))
|
_ = viper.BindPFlag("validate.block-height", stateValidatorCmd.PersistentFlags().Lookup("block-height"))
|
||||||
_ = viper.BindPFlag("validate.trail", stateValidatorCmd.PersistentFlags().Lookup("trail"))
|
_ = viper.BindPFlag("validate.trail", stateValidatorCmd.PersistentFlags().Lookup("trail"))
|
||||||
|
|
||||||
_ = viper.BindPFlag("ethereum.chainConfig", stateValidatorCmd.PersistentFlags().Lookup("chainConfig"))
|
_ = viper.BindPFlag("ethereum.chainConfig", stateValidatorCmd.PersistentFlags().Lookup("chain-config"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func initConfig() {
|
func initConfig() {
|
||||||
@ -82,25 +79,3 @@ func initConfig() {
|
|||||||
log.Warn("No config file passed with --config flag")
|
log.Warn("No config file passed with --config flag")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
|
@ -86,7 +86,6 @@ func (s *service) Start(ctx context.Context) (uint64, error) {
|
|||||||
headBlock, _ := api.B.BlockByNumber(ctx, rpc.LatestBlockNumber)
|
headBlock, _ := api.B.BlockByNumber(ctx, rpc.LatestBlockNumber)
|
||||||
headBlockNum := headBlock.NumberU64()
|
headBlockNum := headBlock.NumberU64()
|
||||||
|
|
||||||
fmt.Println("#########", headBlockNum, s.trail, idxBlockNum)
|
|
||||||
for headBlockNum-s.trail >= idxBlockNum {
|
for headBlockNum-s.trail >= idxBlockNum {
|
||||||
validateBlock, err := api.B.BlockByNumber(ctx, rpc.BlockNumber(idxBlockNum))
|
validateBlock, err := api.B.BlockByNumber(ctx, rpc.BlockNumber(idxBlockNum))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -17,7 +17,8 @@ export DATABASE_USER=vdbm
|
|||||||
export DATABASE_PORT=8077
|
export DATABASE_PORT=8077
|
||||||
export DATABASE_PASSWORD=password
|
export DATABASE_PASSWORD=password
|
||||||
export DATABASE_HOSTNAME=127.0.0.1
|
export DATABASE_HOSTNAME=127.0.0.1
|
||||||
|
export DATABASE_NAME=vulcanize_testing
|
||||||
|
|
||||||
# Wait for containers to be up and execute the integration test.
|
# Wait for containers to be up and execute the integration test.
|
||||||
while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8545)" != "200" ]; do echo "waiting for geth-statediff..." && sleep 5; done && \
|
while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8545)" != "200" ]; do echo "waiting for geth-statediff..." && sleep 5; done && \
|
||||||
make integrationtest
|
make integrationtest
|
||||||
|
Loading…
Reference in New Issue
Block a user