Skip to content

Commit

Permalink
now use firecore rpc clients management
Browse files Browse the repository at this point in the history
  • Loading branch information
billettc committed Jun 27, 2024
1 parent 049ac42 commit a499ee0
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 158 deletions.
20 changes: 10 additions & 10 deletions cmd/firestarknet/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
"strconv"
"time"

snRPC "github.com/NethermindEth/starknet.go/rpc"
starknetRPC "github.com/NethermindEth/starknet.go/rpc"
"github.com/spf13/cobra"
"github.com/streamingfast/cli/sflags"
goRPC "github.com/streamingfast/eth-go/rpc"
ethRPC "github.com/streamingfast/eth-go/rpc"
firecore "github.com/streamingfast/firehose-core"
"github.com/streamingfast/firehose-core/blockpoller"
firecoreRPC "github.com/streamingfast/firehose-core/rpc"
"github.com/streamingfast/logging"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -60,22 +61,21 @@ func fetchRunE(logger *zap.Logger, tracer logging.Tracer) firecore.CommandExecut

latestBlockRetryInterval := sflags.MustGetDuration(cmd, "latest-block-retry-interval")

rpcClients := make([]*snRPC.Provider, 0, len(rpcEndpoints))
starknetClients := firecoreRPC.NewClients[*starknetRPC.Provider]()
for _, rpcEndpoint := range rpcEndpoints {
client, err := snRPC.NewProvider(rpcEndpoint)
client, err := starknetRPC.NewProvider(rpcEndpoint)
if err != nil {
return fmt.Errorf("creating rpc client: %w", err)
}
rpcClients = append(rpcClients, client)
starknetClients.Add(client)
}

ethRpcEndpoints := make([]*goRPC.Client, 0, len(ethEndpoints))
ethClients := firecoreRPC.NewClients[*ethRPC.Client]()
for _, ethEndpoint := range ethEndpoints {
client := goRPC.NewClient(ethEndpoint)
ethRpcEndpoints = append(ethRpcEndpoints, client)
ethClients.Add(ethRPC.NewClient(ethEndpoint))
}
starkClients := rpc.NewRPCClient(ethRpcEndpoints)
rpcFetcher := rpc.NewFetcher(rpcClients, starkClients, fetchLIBContractAddress, fetchInterval, latestBlockRetryInterval, logger)

rpcFetcher := rpc.NewFetcher(starknetClients, ethClients, fetchLIBContractAddress, fetchInterval, latestBlockRetryInterval, logger)

poller := blockpoller.New(
rpcFetcher,
Expand Down
17 changes: 9 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ go 1.22.0

toolchain go1.22.3

//github.com/NethermindEth/starknet.go => github.com/streamingfast/starknet.go v0.0.0-20240611192319-738f3725b214

replace github.com/jhump/protoreflect => github.com/streamingfast/protoreflect v0.0.0-20231205191344-4b629d20ce8d
//replace github.com/streamingfast/firehose-core => ../firehose-core

require (
github.com/NethermindEth/juno v0.3.1
github.com/NethermindEth/starknet.go v0.7.1-0.20240614122559-0d2f96428b45
github.com/hashicorp/go-multierror v1.1.1
github.com/ethereum/go-ethereum v1.13.8
github.com/spf13/cobra v1.8.0
github.com/streamingfast/bstream v0.0.2-0.20240603153252-ec8d37625188
github.com/streamingfast/bstream v0.0.2-0.20240619142813-9d23840859bf
github.com/streamingfast/cli v0.0.4-0.20240412191021-5f81842cb71d
github.com/streamingfast/eth-go v0.0.0-20240312122859-216e183c0b7f
github.com/streamingfast/firehose-core v1.5.1
github.com/streamingfast/firehose-core v1.5.4-0.20240627115820-5e86b3073da6
github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091
go.uber.org/zap v1.27.0
google.golang.org/protobuf v1.33.0
Expand Down Expand Up @@ -69,7 +70,6 @@ require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/envoyproxy/go-control-plane v0.12.0 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
github.com/ethereum/go-ethereum v1.13.8 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fxamacker/cbor/v2 v2.4.0 // indirect
Expand All @@ -90,6 +90,7 @@ require (
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand Down Expand Up @@ -164,7 +165,7 @@ require (
github.com/streamingfast/pbgo v0.0.6-0.20240430190514-722fe9d82e5d // indirect
github.com/streamingfast/sf-tracing v0.0.0-20240430173521-888827872b90 // indirect
github.com/streamingfast/shutter v1.5.0 // indirect
github.com/streamingfast/substreams v1.7.3 // indirect
github.com/streamingfast/substreams v1.8.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/teris-io/shortid v0.0.0-20171029131806-771a37caa5cf // indirect
Expand All @@ -174,7 +175,7 @@ require (
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/whyrusleeping/tar-utils v0.0.0-20180509141711-8c6c8ba81d5c // indirect
github.com/whyrusleeping/tar-utils v0.0.0-20201201191210-20a61371de5b // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/yourbasic/graph v0.0.0-20210606180040-8ecfec1c2869 // indirect
go.opencensus.io v0.24.0 // indirect
Expand All @@ -190,7 +191,7 @@ require (
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/automaxprocs v1.5.2 // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.22.0 // indirect
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU=
github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA=
github.com/streamingfast/bstream v0.0.2-0.20240603153252-ec8d37625188 h1:aso0Q0qT9h1ICG6//G9P0VQpql2c2A87J8YMUaJipQs=
github.com/streamingfast/bstream v0.0.2-0.20240603153252-ec8d37625188/go.mod h1:n5wy+Vmwp4xbjXO7B81MAkAgjnf1vJ/lI2y6hWWyFbg=
github.com/streamingfast/bstream v0.0.2-0.20240619142813-9d23840859bf h1:LXFIz2pyTlIMNzyifvKsZpFLcLbJkTcRyu7OlABV1S0=
github.com/streamingfast/bstream v0.0.2-0.20240619142813-9d23840859bf/go.mod h1:n5wy+Vmwp4xbjXO7B81MAkAgjnf1vJ/lI2y6hWWyFbg=
github.com/streamingfast/cli v0.0.4-0.20240412191021-5f81842cb71d h1:9tsEt2tLCp94CW6MyJZY+Rw6+t0WH2kioBR6ucO6P/E=
github.com/streamingfast/cli v0.0.4-0.20240412191021-5f81842cb71d/go.mod h1:og+6lDBPLZ24lbF/YISmVsSduZUZwXSmJGD3pZ/sW2Y=
github.com/streamingfast/dauth v0.0.0-20240222213226-519afc16cf84 h1:yCvuNcwQ21J4Ua6YrAmHDBx3bjK04y+ssEYBe65BXRU=
Expand All @@ -585,8 +585,8 @@ github.com/streamingfast/dtracing v0.0.0-20220305214756-b5c0e8699839 h1:K6mJPvh1
github.com/streamingfast/dtracing v0.0.0-20220305214756-b5c0e8699839/go.mod h1:huOJyjMYS6K8upTuxDxaNd+emD65RrXoVBvh8f1/7Ns=
github.com/streamingfast/eth-go v0.0.0-20240312122859-216e183c0b7f h1:1LwsmRVENfGsPHrVEOCJ7FKQ1YyFcg7+USuHdd/TIkw=
github.com/streamingfast/eth-go v0.0.0-20240312122859-216e183c0b7f/go.mod h1:UEm8dqibr3c3A1iIA3CHpkhN7j3X78prN7/55sXf3A0=
github.com/streamingfast/firehose-core v1.5.1 h1:BiX3okg3Wl/NVFfX76SaXOWRndQpfyeIYiVk04VbbwM=
github.com/streamingfast/firehose-core v1.5.1/go.mod h1:xUHlSTxMnGTvB+YVHtv4MCh/SXxlhg5puHMrTXHSe0I=
github.com/streamingfast/firehose-core v1.5.4-0.20240627115820-5e86b3073da6 h1:ooT7/FlCZ2W50TmYVr9qSTGhN91bhaWxIYnYGc2pqRs=
github.com/streamingfast/firehose-core v1.5.4-0.20240627115820-5e86b3073da6/go.mod h1:TXmSr7tnJdqcDrYG2l+BwURjX0rGYKsUNcWkcL6GROw=
github.com/streamingfast/jsonpb v0.0.0-20210811021341-3670f0aa02d0 h1:g8eEYbFSykyzIyuxNMmHEUGGUvJE0ivmqZagLDK42gw=
github.com/streamingfast/jsonpb v0.0.0-20210811021341-3670f0aa02d0/go.mod h1:cTNObq2Uofb330y05JbbZZ6RwE6QUXw5iVcHk1Fx3fk=
github.com/streamingfast/logging v0.0.0-20210811175431-f3b44b61606a/go.mod h1:4GdqELhZOXj4xwc4IaBmzofzdErGynnaSzuzxy0ZIBo=
Expand All @@ -604,8 +604,8 @@ github.com/streamingfast/sf-tracing v0.0.0-20240430173521-888827872b90 h1:94Hllk
github.com/streamingfast/sf-tracing v0.0.0-20240430173521-888827872b90/go.mod h1:e6tKS/udlfXFUTQBYfDDdISfjULvQXet1kBrOeRfgI4=
github.com/streamingfast/shutter v1.5.0 h1:NpzDYzj0HVpSiDJVO/FFSL6QIK/YKOxY0gJAtyaTOgs=
github.com/streamingfast/shutter v1.5.0/go.mod h1:B/T6efqdeMGbGwjzPS1ToXzYZI4kDzI5/u4I+7qbjY8=
github.com/streamingfast/substreams v1.7.3 h1:V4YOJt4tAzivaLpC7nSVDdULMuczj7QfJUTyHAT2qkM=
github.com/streamingfast/substreams v1.7.3/go.mod h1:ao5xpjglDohCmwzRUlJtTNGUn+nXGR2AXBnYQEbvQaI=
github.com/streamingfast/substreams v1.8.0 h1:mVo6TTVRcwLB1TuFdZXI1GBVJnmREfJEt8sRFybWkLQ=
github.com/streamingfast/substreams v1.8.0/go.mod h1:XtL4RgQawes9/a9iM9d6bAABacfIuekY+jceszF7u2c=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
Expand Down Expand Up @@ -640,8 +640,8 @@ github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0h
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
github.com/tsenart/deadcode v0.0.0-20160724212837-210d2dc333e9/go.mod h1:q+QjxYvZ+fpjMXqs+XEriussHjSYqeXVnAdSV1tkMYk=
github.com/whyrusleeping/tar-utils v0.0.0-20180509141711-8c6c8ba81d5c h1:GGsyl0dZ2jJgVT+VvWBf/cNijrHRhkrTjkmp5wg7li0=
github.com/whyrusleeping/tar-utils v0.0.0-20180509141711-8c6c8ba81d5c/go.mod h1:xxcJeBb7SIUl/Wzkz1eVKJE/CB34YNrqX2TQI6jY9zs=
github.com/whyrusleeping/tar-utils v0.0.0-20201201191210-20a61371de5b h1:wA3QeTsaAXybLL2kb2cKhCAQTHgYTMwuI8lBlJSv5V8=
github.com/whyrusleeping/tar-utils v0.0.0-20201201191210-20a61371de5b/go.mod h1:xT1Y5p2JR2PfSZihE0s4mjdJaRGp1waCTf5JzhQLBck=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/yourbasic/graph v0.0.0-20210606180040-8ecfec1c2869 h1:7v7L5lsfw4w8iqBBXETukHo4IPltmD+mWoLRYUmeGN8=
Expand Down Expand Up @@ -712,8 +712,8 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down
Loading

0 comments on commit a499ee0

Please sign in to comment.