Setup validator config and update instructions to run tests locally
This commit is contained in:
parent
3182a60794
commit
44fb305858
@ -7,7 +7,6 @@ import (
|
||||
"os/signal"
|
||||
"sync"
|
||||
|
||||
"github.com/ethereum/go-ethereum/statediff"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
@ -34,20 +33,7 @@ func stateValidator() {
|
||||
logWithCommand.Fatal(err)
|
||||
}
|
||||
|
||||
height := viper.GetUint64("validate.block-height")
|
||||
if height < 1 {
|
||||
logWithCommand.Fatalf("block height cannot be less the 1")
|
||||
}
|
||||
trail := viper.GetUint64("validate.trail")
|
||||
sleepInterval := viper.GetUint("validate.sleepInterval")
|
||||
|
||||
chainConfigPath := viper.GetString("ethereum.chainConfig")
|
||||
chainCfg, err := statediff.LoadConfig(chainConfigPath)
|
||||
if err != nil {
|
||||
logWithCommand.Fatal(err)
|
||||
}
|
||||
|
||||
service := validator.NewService(cfg.DB, height, trail, sleepInterval, chainCfg, nil)
|
||||
service := validator.NewService(cfg, nil)
|
||||
|
||||
wg := new(sync.WaitGroup)
|
||||
wg.Add(1)
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/statediff"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/spf13/viper"
|
||||
@ -59,11 +60,35 @@ var TestChainConfig = ¶ms.ChainConfig{
|
||||
type Config struct {
|
||||
dbConfig postgres.Config
|
||||
DB *sqlx.DB
|
||||
|
||||
ChainCfg *params.ChainConfig
|
||||
|
||||
BlockNum, Trail uint64
|
||||
SleepInterval uint
|
||||
}
|
||||
|
||||
func NewConfig() (*Config, error) {
|
||||
cfg := new(Config)
|
||||
return cfg, cfg.setupDB()
|
||||
err := cfg.setupDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cfg.BlockNum = viper.GetUint64("validate.block-height")
|
||||
if cfg.BlockNum < 1 {
|
||||
return nil, fmt.Errorf("block height cannot be less the 1")
|
||||
}
|
||||
|
||||
cfg.Trail = viper.GetUint64("validate.trail")
|
||||
cfg.SleepInterval = viper.GetUint("validate.sleepInterval")
|
||||
|
||||
chainConfigPath := viper.GetString("ethereum.chainConfig")
|
||||
cfg.ChainCfg, err = statediff.LoadConfig(chainConfigPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
func (c *Config) setupDB() error {
|
||||
|
@ -40,14 +40,14 @@ type service struct {
|
||||
progressChan chan uint64
|
||||
}
|
||||
|
||||
func NewService(db *sqlx.DB, blockNum, trailNum uint64, sleepInterval uint, chainCfg *params.ChainConfig, progressChan chan uint64) *service {
|
||||
func NewService(cfg *Config, progressChan chan uint64) *service {
|
||||
return &service{
|
||||
db: db,
|
||||
blockNum: blockNum,
|
||||
trail: trailNum,
|
||||
sleepInterval: sleepInterval,
|
||||
db: cfg.DB,
|
||||
blockNum: cfg.BlockNum,
|
||||
trail: cfg.Trail,
|
||||
sleepInterval: cfg.SleepInterval,
|
||||
logger: log.New(),
|
||||
chainCfg: chainCfg,
|
||||
chainCfg: cfg.ChainCfg,
|
||||
quitChan: make(chan bool),
|
||||
progressChan: progressChan,
|
||||
}
|
||||
|
@ -6,18 +6,18 @@
|
||||
|
||||
- Clone [stack-orchestrator](https://github.com/vulcanize/stack-orchestrator) and [go-ethereum](https://github.com/vulcanize/go-ethereum) repositories.
|
||||
|
||||
- Checkout [v3 release](https://github.com/vulcanize/go-ethereum/releases/tag/v1.10.17-statediff-3.2.1) in go-ethereum repo.
|
||||
- Checkout [v3 release](https://github.com/vulcanize/go-ethereum/releases/tag/v1.10.18-statediff-3.2.2) in go-ethereum repo.
|
||||
|
||||
```bash
|
||||
# In go-ethereum repo.
|
||||
git checkout v1.10.17-statediff-3.2.1
|
||||
git checkout v1.10.18-statediff-3.2.2
|
||||
```
|
||||
|
||||
- Checkout working commit in stack-orchestrator repo.
|
||||
|
||||
```bash
|
||||
# In stack-orchestrator repo.
|
||||
git checkout 3bb1796a59827fb755410c5ce69fac567a0f832b
|
||||
git checkout main
|
||||
```
|
||||
|
||||
## Run
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
blockNum = 1
|
||||
trail = 0
|
||||
validatorSleepInterval = uint(5)
|
||||
)
|
||||
@ -44,8 +45,15 @@ var _ = Describe("Integration test", func() {
|
||||
timeout := 4 * time.Second
|
||||
|
||||
db := shared.SetupDB()
|
||||
cfg := validator.Config{
|
||||
DB: db,
|
||||
BlockNum: blockNum,
|
||||
Trail: trail,
|
||||
SleepInterval: validatorSleepInterval,
|
||||
ChainCfg: validator.IntegrationTestChainConfig,
|
||||
}
|
||||
validationProgressChan := make(chan uint64)
|
||||
service := validator.NewService(db, 1, trail, validatorSleepInterval, validator.IntegrationTestChainConfig, validationProgressChan)
|
||||
service := validator.NewService(&cfg, validationProgressChan)
|
||||
|
||||
wg := new(sync.WaitGroup)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user