From 7bb27714db289485651120f87f91ed733c5bc54a Mon Sep 17 00:00:00 2001 From: Ian Norden Date: Thu, 10 Sep 2020 17:27:18 -0500 Subject: [PATCH 1/4] store chainID in node info table --- cmd/root.go | 4 +--- db/migrations/00001_create_nodes_table.sql | 3 ++- db/schema.sql | 26 ++++++++++++++++++++-- environments/example.toml | 7 ++++++ pkg/helpers/test_helpers/database.go | 5 ++--- pkg/testing/helpers.go | 2 +- 6 files changed, 37 insertions(+), 10 deletions(-) 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/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{ From 2b5259e56548b0e53d273dab41577d9a9d8b2b16 Mon Sep 17 00:00:00 2001 From: Ian Norden Date: Thu, 10 Sep 2020 17:37:33 -0500 Subject: [PATCH 2/4] v0.1.0-alpha tag --- version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ) From 54470e23c6306f23a9031f4d054c38b97aa000b4 Mon Sep 17 00:00:00 2001 From: Ian Norden Date: Thu, 10 Sep 2020 17:41:59 -0500 Subject: [PATCH 3/4] use eth-header-sync v0.1.1 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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= From 52aa9096526bcf5985e5e57b0a5139c2febe0e7d Mon Sep 17 00:00:00 2001 From: Ian Norden Date: Thu, 10 Sep 2020 20:33:54 -0500 Subject: [PATCH 4/4] update README --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) 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.