Skip to content
This repository was archived by the owner on Jan 12, 2022. It is now read-only.

Commit 240e257

Browse files
authored
Merge pull request #22 from vulcanize/fix
Fix
2 parents 72facc7 + 52aa909 commit 240e257

File tree

10 files changed

+49
-12
lines changed

10 files changed

+49
-12
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ The config file linked to in the `--config` cli flag should have the below forma
160160
]
161161
startingBlock = 4448566
162162
piping = true
163+
164+
[ethereum]
165+
nodeID = "arch1"
166+
clientName = "Geth"
167+
genesisBlock = "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"
168+
networkID = "1"
169+
chainID = "1"
163170
````
164171

165172
- `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
188195
- If methodArgs are provided then only those values will be used to poll methods
189196
- `startingBlock` is the block we want to begin watching the contract, usually the deployment block of that contract
190197
- `piping` is a boolean flag which indicates whether or not we want to pipe return method values forward as arguments to subsequent method calls
198+
- `ethereum` fields hold information for the Ethereum node, network, and chain
191199

192200
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).
193201
With just this information we will be able to watch all events at the contract, but with no additional filters and no method polling.

cmd/root.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"github.com/spf13/cobra"
2828
"github.com/spf13/viper"
2929

30-
"github.com/vulcanize/eth-header-sync/pkg/client"
3130
hc "github.com/vulcanize/eth-header-sync/pkg/config"
3231
"github.com/vulcanize/eth-header-sync/pkg/core"
3332
"github.com/vulcanize/eth-header-sync/pkg/node"
@@ -151,6 +150,5 @@ func getClientAndNode() (*ethclient.Client, core.Node) {
151150
if err != nil {
152151
logWithCommand.Fatal(err)
153152
}
154-
rpcClient := client.NewRPCClient(rawRPCClient, ipc)
155-
return ethclient.NewClient(rawRPCClient), node.MakeNode(rpcClient)
153+
return ethclient.NewClient(rawRPCClient), node.MakeNode()
156154
}

db/migrations/00001_create_nodes_table.sql

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ CREATE TABLE nodes (
55
genesis_block VARCHAR(66),
66
network_id VARCHAR,
77
node_id VARCHAR(128),
8-
CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id)
8+
chain_id INTEGER,
9+
CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id, chain_id)
910
);
1011

1112
-- +goose Down

db/schema.sql

+24-2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ CREATE TABLE public.headers (
9898
);
9999

100100

101+
--
102+
-- Name: COLUMN headers.node_id; Type: COMMENT; Schema: public; Owner: -
103+
--
104+
105+
COMMENT ON COLUMN public.headers.node_id IS '@name HeaderNodeID';
106+
107+
101108
--
102109
-- Name: headers_id_seq; Type: SEQUENCE; Schema: public; Owner: -
103110
--
@@ -127,10 +134,25 @@ CREATE TABLE public.nodes (
127134
client_name character varying,
128135
genesis_block character varying(66),
129136
network_id character varying,
130-
node_id character varying(128)
137+
node_id character varying(128),
138+
chain_id integer
131139
);
132140

133141

142+
--
143+
-- Name: TABLE nodes; Type: COMMENT; Schema: public; Owner: -
144+
--
145+
146+
COMMENT ON TABLE public.nodes IS '@name NodeInfo';
147+
148+
149+
--
150+
-- Name: COLUMN nodes.node_id; Type: COMMENT; Schema: public; Owner: -
151+
--
152+
153+
COMMENT ON COLUMN public.nodes.node_id IS '@name ChainNodeID';
154+
155+
134156
--
135157
-- Name: nodes_id_seq; Type: SEQUENCE; Schema: public; Owner: -
136158
--
@@ -224,7 +246,7 @@ ALTER TABLE ONLY public.headers
224246
--
225247

226248
ALTER TABLE ONLY public.nodes
227-
ADD CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id);
249+
ADD CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id, chain_id);
228250

229251

230252
--

environments/example.toml

+7
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,12 @@
2323
]
2424
startingBlock = 10564606
2525

26+
[ethereum]
27+
nodeID = "arch1" # $ETH_NODE_ID
28+
clientName = "Geth" # $ETH_CLIENT_NAME
29+
genesisBlock = "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" # $ETH_GENESIS_BLOCK
30+
networkID = "1" # $ETH_NETWORK_ID
31+
chainID = "1" # $ETH_CHAIN_ID
32+
2633
#[log]
2734
# level = "debug"

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/sirupsen/logrus v1.6.0
1414
github.com/spf13/cobra v1.0.0
1515
github.com/spf13/viper v1.7.0
16-
github.com/vulcanize/eth-header-sync v0.0.10-alpha
16+
github.com/vulcanize/eth-header-sync v0.1.1
1717
golang.org/x/net v0.0.0-20200528225125-3c3fba18258b
1818
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
1919
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljT
368368
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
369369
github.com/vulcanize/eth-header-sync v0.0.10-alpha h1:GYwpmp29c82voUmPrnRRWCAOO8eSdSkFazsaq4uaEhU=
370370
github.com/vulcanize/eth-header-sync v0.0.10-alpha/go.mod h1:fAPFg1SipuMJ8gyLBuCzCXFRcT0PVCbXlA0E0MaoYTI=
371+
github.com/vulcanize/eth-header-sync v0.1.1 h1:XTGbeOfP8c1X4qshIAbLHRzBqTO3zSIsj2J6+8BBbGw=
372+
github.com/vulcanize/eth-header-sync v0.1.1/go.mod h1:fAPFg1SipuMJ8gyLBuCzCXFRcT0PVCbXlA0E0MaoYTI=
371373
github.com/vulcanize/vulcanizedb v0.0.9 h1:ozV2t/MG4/WLgP89blPOw4r1KwM5ji9+DW9CXPGFX08=
372374
github.com/vulcanize/vulcanizedb v0.0.9/go.mod h1:9zfi6VIiCrDVHXe9Z0xmW4CDmNPFwdLuHLcRjjSrdLQ=
373375
github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208 h1:1cngl9mPEoITZG8s8cVcUy5CeIBYhEESkOB7m6Gmkrk=

pkg/helpers/test_helpers/database.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func SetupHeaderFetcher() core.Fetcher {
111111
Expect(err).NotTo(HaveOccurred())
112112
ethClient := ethclient.NewClient(rawRPCClient)
113113
rpcClient := client.NewRPCClient(rawRPCClient, rpcPath)
114-
n := node.MakeNode(rpcClient)
114+
n := node.MakeNode()
115115
Expect(err).NotTo(HaveOccurred())
116116

117117
return fetcher.NewFetcher(ethClient, rpcClient, n)
@@ -123,8 +123,7 @@ func SetupDBandClient() (*postgres.DB, core.EthClient) {
123123
rawRPCClient, err := rpc.Dial(rpcPath)
124124
Expect(err).NotTo(HaveOccurred())
125125
ethClient := ethclient.NewClient(rawRPCClient)
126-
rpcClient := client.NewRPCClient(rawRPCClient, rpcPath)
127-
n := node.MakeNode(rpcClient)
126+
n := node.MakeNode()
128127

129128
db, err := postgres.NewDB(config.Database{
130129
Hostname: "localhost",

pkg/testing/helpers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"github.com/vulcanize/eth-contract-watcher/pkg/core"
2626
)
2727

28-
var TestABIsPath = os.Getenv("GOPATH") + "/src/github.com/vulcanize/vulcanizedb/pkg/eth/testing/"
28+
var TestABIsPath = os.Getenv("GOPATH") + "/src/github.com/vulcanize/eth-contract-watcher/pkg/testing/"
2929

3030
func SampleContract() core.Contract {
3131
return core.Contract{

version/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import "fmt"
2121
const (
2222
Major = 0 // Major version component of the current release
2323
Minor = 1 // Minor version component of the current release
24-
Patch = 2 // Patch version component of the current release
24+
Patch = 0 // Patch version component of the current release
2525
Meta = "alpha" // Version metadata to append to the version string
2626
)
2727

0 commit comments

Comments
 (0)