diff --git a/go.mod b/go.mod index e05f5011..69b9ed70 100644 --- a/go.mod +++ b/go.mod @@ -28,4 +28,4 @@ require ( github.com/vulcanize/ipfs-ethdb/v3 v3.0.1 ) -replace github.com/ethereum/go-ethereum v1.10.17 => github.com/vulcanize/go-ethereum v1.10.17-statediff-3.2.0 +replace github.com/ethereum/go-ethereum v1.10.17 => github.com/vulcanize/go-ethereum v1.10.17-statediff-3.2.1 diff --git a/go.sum b/go.sum index a1866817..2118e8df 100644 --- a/go.sum +++ b/go.sum @@ -1838,8 +1838,8 @@ github.com/vulcanize/eth-ipfs-state-validator/v3 v3.0.0 h1:hQcbewsJX5Xpd3xdE9n3J github.com/vulcanize/eth-ipfs-state-validator/v3 v3.0.0/go.mod h1:CuuygZPciwwLV5vNY1LcIi0PZxXZbOmicw1/IkrPpPI= github.com/vulcanize/gap-filler v0.3.1 h1:N5d+jCJo/VTWFvBSbTD7biRhK/OqDZzi1tgA85SIBKs= github.com/vulcanize/gap-filler v0.3.1/go.mod h1:qowG1cgshVpBqMokiWro/1xhh0uypw7oAu8FQ42JMy4= -github.com/vulcanize/go-ethereum v1.10.17-statediff-3.2.0 h1:BfExzgnQhpJesYFiwMAHGTYwPWBTwXEQiSvBWJnYhr4= -github.com/vulcanize/go-ethereum v1.10.17-statediff-3.2.0/go.mod h1:mDwZX+QoWdqzQo6SDG3YVqCYACutcSG6uzpziMvTu28= +github.com/vulcanize/go-ethereum v1.10.17-statediff-3.2.1 h1:BUIaiqqsWM61KfzIowqrGJ8TM2SWwmral4iJ/nhTSe0= +github.com/vulcanize/go-ethereum v1.10.17-statediff-3.2.1/go.mod h1:mDwZX+QoWdqzQo6SDG3YVqCYACutcSG6uzpziMvTu28= github.com/vulcanize/ipfs-ethdb/v3 v3.0.1 h1:gm+6SgxcNOCz6mgwvhsxORLXsr9yIFvbJDuoAK85ONs= github.com/vulcanize/ipfs-ethdb/v3 v3.0.1/go.mod h1:SPBTTl5CqRexYfkI66pbzE5nQziYpoQ+7hH0XveA9IU= github.com/wangjia184/sortedset v0.0.0-20160527075905-f5d03557ba30/go.mod h1:YkocrP2K2tcw938x9gCOmT5G5eCD6jsTz0SZuyAqwIE= diff --git a/pkg/eth/helpers.go b/pkg/eth/helpers.go index b4d4f679..f9a995fc 100644 --- a/pkg/eth/helpers.go +++ b/pkg/eth/helpers.go @@ -17,16 +17,7 @@ package eth import ( - "encoding/json" - "fmt" - "os" - - "github.com/ethereum/go-ethereum/cmd/utils" - log "github.com/sirupsen/logrus" - sdtypes "github.com/ethereum/go-ethereum/statediff/types" - - "github.com/ethereum/go-ethereum/params" ) func ResolveToNodeType(nodeType int) sdtypes.NodeType { @@ -43,41 +34,3 @@ func ResolveToNodeType(nodeType int) sdtypes.NodeType { return sdtypes.Unknown } } - -// LoadConfig loads chain config from json file -func LoadConfig(chainConfigPath string) (*params.ChainConfig, error) { - file, err := os.Open(chainConfigPath) - if err != nil { - utils.Fatalf("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 { - utils.Fatalf("invalid chain config file: %v", err) - - return nil, err - } - - log.Infof("Using chain config from %s file. Content %+v", chainConfigPath, chainConfig) - - return chainConfig, nil -} - -// ChainConfig returns the appropriate ethereum chain config for the provided chain id -func ChainConfig(chainID uint64) (*params.ChainConfig, error) { - switch chainID { - case 1: - return params.MainnetChainConfig, nil - case 3: - return params.RopstenChainConfig, nil - case 4: - return params.RinkebyChainConfig, nil - case 5: - return params.GoerliChainConfig, nil - default: - return nil, fmt.Errorf("chain config for chainid %d not available", chainID) - } -} diff --git a/pkg/serve/config.go b/pkg/serve/config.go index 7f61b27e..930ea309 100644 --- a/pkg/serve/config.go +++ b/pkg/serve/config.go @@ -27,13 +27,12 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" + "github.com/ethereum/go-ethereum/statediff" "github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres" "github.com/jmoiron/sqlx" "github.com/spf13/viper" - "github.com/vulcanize/ipld-eth-server/pkg/eth" "github.com/vulcanize/ipld-eth-server/pkg/prom" - "github.com/vulcanize/ipld-eth-server/pkg/shared" ethServerShared "github.com/vulcanize/ipld-eth-server/pkg/shared" ) @@ -208,7 +207,7 @@ func NewConfig() (*Config, error) { c.IpldGraphqlEnabled = ipldGraphqlEnabled overrideDBConnConfig(&c.DBConfig) - serveDB, err := shared.NewDB(c.DBConfig.DbConnectionString(), c.DBConfig) + serveDB, err := ethServerShared.NewDB(c.DBConfig.DbConnectionString(), c.DBConfig) if err != nil { return nil, err } @@ -229,9 +228,9 @@ func NewConfig() (*Config, error) { } chainConfigPath := viper.GetString("ethereum.chainConfig") if chainConfigPath != "" { - c.ChainConfig, err = eth.LoadConfig(chainConfigPath) + c.ChainConfig, err = statediff.LoadConfig(chainConfigPath) } else { - c.ChainConfig, err = eth.ChainConfig(nodeInfo.ChainID) + c.ChainConfig, err = statediff.ChainConfig(nodeInfo.ChainID) } c.loadGroupCacheConfig() diff --git a/scripts/run_unit_test.sh b/scripts/run_unit_test.sh index bf9db9d9..27f7e2ef 100755 --- a/scripts/run_unit_test.sh +++ b/scripts/run_unit_test.sh @@ -1,7 +1,7 @@ # Clear up existing docker images and volume. docker-compose down --remove-orphans --volumes -docker-compose -f docker-compose.test.yml -f docker-compose.yml up -d ipld-eth-db +docker-compose -f docker-compose.yml up -d ipld-eth-db sleep 10 PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8077 DATABASE_PASSWORD=password DATABASE_HOSTNAME=127.0.0.1 DATABASE_NAME=vulcanize_testing make test