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

Commit

Permalink
Merge pull request #22 from vulcanize/fix
Browse files Browse the repository at this point in the history
Fix
  • Loading branch information
ramilexe authored Sep 11, 2020
2 parents 72facc7 + 52aa909 commit 240e257
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 12 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
}
3 changes: 2 additions & 1 deletion db/migrations/00001_create_nodes_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 24 additions & 2 deletions db/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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: -
--
Expand Down Expand Up @@ -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: -
--
Expand Down Expand Up @@ -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);


--
Expand Down
7 changes: 7 additions & 0 deletions environments/example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
5 changes: 2 additions & 3 deletions pkg/helpers/test_helpers/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion pkg/testing/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down

0 comments on commit 240e257

Please sign in to comment.