diff --git a/README.md b/README.md index 4dbcf4dd..8fad4a9f 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,13 @@ The config file linked to in the `--config` cli flag should have the below forma ] startingBlock = 4448566 piping = true + + [ethereum] + nodeID = "arch1" + clientName = "Geth" + genesisBlock = "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" + networkID = "1" + chainID = "1" ```` - `database` fields hold the paramaters for connection to the Postgres database @@ -188,6 +195,7 @@ The config file linked to in the `--config` cli flag should have the below forma - If methodArgs are provided then only those values will be used to poll methods - `startingBlock` is the block we want to begin watching the contract, usually the deployment block of that contract - `piping` is a boolean flag which indicates whether or not we want to pipe return method values forward as arguments to subsequent method calls +- `ethereum` fields hold information for the Ethereum node, network, and chain At the very minimum, for each contract address an ABI and a starting block number need to be provided (or just the starting block if the ABI can be reliably fetched from Etherscan). With just this information we will be able to watch all events at the contract, but with no additional filters and no method polling. diff --git a/cmd/root.go b/cmd/root.go index a7cd1dc2..3438edb2 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -27,7 +27,6 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/vulcanize/eth-header-sync/pkg/client" hc "github.com/vulcanize/eth-header-sync/pkg/config" "github.com/vulcanize/eth-header-sync/pkg/core" "github.com/vulcanize/eth-header-sync/pkg/node" @@ -151,6 +150,5 @@ func getClientAndNode() (*ethclient.Client, core.Node) { if err != nil { logWithCommand.Fatal(err) } - rpcClient := client.NewRPCClient(rawRPCClient, ipc) - return ethclient.NewClient(rawRPCClient), node.MakeNode(rpcClient) + return ethclient.NewClient(rawRPCClient), node.MakeNode() } diff --git a/db/migrations/00001_create_nodes_table.sql b/db/migrations/00001_create_nodes_table.sql index 76db3d71..909d5789 100644 --- a/db/migrations/00001_create_nodes_table.sql +++ b/db/migrations/00001_create_nodes_table.sql @@ -5,7 +5,8 @@ CREATE TABLE nodes ( genesis_block VARCHAR(66), network_id VARCHAR, node_id VARCHAR(128), - CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id) + chain_id INTEGER, + CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id, chain_id) ); -- +goose Down diff --git a/db/schema.sql b/db/schema.sql index cd03be1a..884c3026 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -98,6 +98,13 @@ CREATE TABLE public.headers ( ); +-- +-- Name: COLUMN headers.node_id; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.headers.node_id IS '@name HeaderNodeID'; + + -- -- Name: headers_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- @@ -127,10 +134,25 @@ CREATE TABLE public.nodes ( client_name character varying, genesis_block character varying(66), network_id character varying, - node_id character varying(128) + node_id character varying(128), + chain_id integer ); +-- +-- Name: TABLE nodes; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.nodes IS '@name NodeInfo'; + + +-- +-- Name: COLUMN nodes.node_id; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.nodes.node_id IS '@name ChainNodeID'; + + -- -- Name: nodes_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- @@ -224,7 +246,7 @@ ALTER TABLE ONLY public.headers -- ALTER TABLE ONLY public.nodes - ADD CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id); + ADD CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id, chain_id); -- diff --git a/environments/example.toml b/environments/example.toml index 5169bfc9..cb2cf2fc 100644 --- a/environments/example.toml +++ b/environments/example.toml @@ -23,5 +23,12 @@ ] startingBlock = 10564606 +[ethereum] + nodeID = "arch1" # $ETH_NODE_ID + clientName = "Geth" # $ETH_CLIENT_NAME + genesisBlock = "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" # $ETH_GENESIS_BLOCK + networkID = "1" # $ETH_NETWORK_ID + chainID = "1" # $ETH_CHAIN_ID + #[log] # level = "debug" \ No newline at end of file diff --git a/go.mod b/go.mod index 756716e2..a3bb66bf 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/sirupsen/logrus v1.6.0 github.com/spf13/cobra v1.0.0 github.com/spf13/viper v1.7.0 - github.com/vulcanize/eth-header-sync v0.0.10-alpha + github.com/vulcanize/eth-header-sync v0.1.1 golang.org/x/net v0.0.0-20200528225125-3c3fba18258b golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 diff --git a/go.sum b/go.sum index 8288228b..c30698f8 100644 --- a/go.sum +++ b/go.sum @@ -368,6 +368,8 @@ github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljT github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/vulcanize/eth-header-sync v0.0.10-alpha h1:GYwpmp29c82voUmPrnRRWCAOO8eSdSkFazsaq4uaEhU= github.com/vulcanize/eth-header-sync v0.0.10-alpha/go.mod h1:fAPFg1SipuMJ8gyLBuCzCXFRcT0PVCbXlA0E0MaoYTI= +github.com/vulcanize/eth-header-sync v0.1.1 h1:XTGbeOfP8c1X4qshIAbLHRzBqTO3zSIsj2J6+8BBbGw= +github.com/vulcanize/eth-header-sync v0.1.1/go.mod h1:fAPFg1SipuMJ8gyLBuCzCXFRcT0PVCbXlA0E0MaoYTI= github.com/vulcanize/vulcanizedb v0.0.9 h1:ozV2t/MG4/WLgP89blPOw4r1KwM5ji9+DW9CXPGFX08= github.com/vulcanize/vulcanizedb v0.0.9/go.mod h1:9zfi6VIiCrDVHXe9Z0xmW4CDmNPFwdLuHLcRjjSrdLQ= github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208 h1:1cngl9mPEoITZG8s8cVcUy5CeIBYhEESkOB7m6Gmkrk= diff --git a/pkg/helpers/test_helpers/database.go b/pkg/helpers/test_helpers/database.go index 071ccf53..f1689809 100644 --- a/pkg/helpers/test_helpers/database.go +++ b/pkg/helpers/test_helpers/database.go @@ -111,7 +111,7 @@ func SetupHeaderFetcher() core.Fetcher { Expect(err).NotTo(HaveOccurred()) ethClient := ethclient.NewClient(rawRPCClient) rpcClient := client.NewRPCClient(rawRPCClient, rpcPath) - n := node.MakeNode(rpcClient) + n := node.MakeNode() Expect(err).NotTo(HaveOccurred()) return fetcher.NewFetcher(ethClient, rpcClient, n) @@ -123,8 +123,7 @@ func SetupDBandClient() (*postgres.DB, core.EthClient) { rawRPCClient, err := rpc.Dial(rpcPath) Expect(err).NotTo(HaveOccurred()) ethClient := ethclient.NewClient(rawRPCClient) - rpcClient := client.NewRPCClient(rawRPCClient, rpcPath) - n := node.MakeNode(rpcClient) + n := node.MakeNode() db, err := postgres.NewDB(config.Database{ Hostname: "localhost", diff --git a/pkg/testing/helpers.go b/pkg/testing/helpers.go index b9e74e72..ac74e96c 100644 --- a/pkg/testing/helpers.go +++ b/pkg/testing/helpers.go @@ -25,7 +25,7 @@ import ( "github.com/vulcanize/eth-contract-watcher/pkg/core" ) -var TestABIsPath = os.Getenv("GOPATH") + "/src/github.com/vulcanize/vulcanizedb/pkg/eth/testing/" +var TestABIsPath = os.Getenv("GOPATH") + "/src/github.com/vulcanize/eth-contract-watcher/pkg/testing/" func SampleContract() core.Contract { return core.Contract{ diff --git a/version/version.go b/version/version.go index b36e5f4a..04e5e6a6 100644 --- a/version/version.go +++ b/version/version.go @@ -21,7 +21,7 @@ import "fmt" const ( Major = 0 // Major version component of the current release Minor = 1 // Minor version component of the current release - Patch = 2 // Patch version component of the current release + Patch = 0 // Patch version component of the current release Meta = "alpha" // Version metadata to append to the version string )