Skip to content

Commit

Permalink
Merge branch 'develop' into feature/codegen-cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBger committed Aug 26, 2024
2 parents 32ad834 + 7d7c7b1 commit ea8d22e
Show file tree
Hide file tree
Showing 24 changed files with 763 additions and 496 deletions.
43 changes: 42 additions & 1 deletion app/tier1.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import (
"net/url"
"time"

"connectrpc.com/connect"
"github.com/streamingfast/substreams/pb/sf/substreams/rpc/v2/pbsubstreamsrpcconnect"
ssconnect "github.com/streamingfast/substreams/pb/sf/substreams/rpc/v2/pbsubstreamsrpcconnect"
"github.com/streamingfast/substreams/reqctx"
"github.com/streamingfast/substreams/wasm/wazero"

"github.com/streamingfast/bstream"
"github.com/streamingfast/bstream/blockstream"
Expand All @@ -15,6 +19,7 @@ import (
dauth "github.com/streamingfast/dauth"
"github.com/streamingfast/dmetrics"
"github.com/streamingfast/dstore"
pbfirehose "github.com/streamingfast/pbgo/sf/firehose/v2"
"github.com/streamingfast/shutter"
"github.com/streamingfast/substreams/client"
"github.com/streamingfast/substreams/metrics"
Expand All @@ -30,6 +35,12 @@ type Tier1Modules struct {
HeadTimeDriftMetric *dmetrics.HeadTimeDrift
HeadBlockNumberMetric *dmetrics.HeadBlockNum
CheckPendingShutDown func() bool
InfoServer InfoServer
}

type InfoServer interface {
Init(ctx context.Context, fhub *hub.ForkableHub, mergedBlocksStore dstore.Store, oneBlockStore dstore.Store, logger *zap.Logger) error
Info(ctx context.Context, request *pbfirehose.InfoRequest) (*pbfirehose.InfoResponse, error)
}

type Tier1Config struct {
Expand All @@ -43,6 +54,7 @@ type Tier1Config struct {
GRPCShutdownGracePeriod time.Duration // The duration we allow for gRPC connections to terminate gracefully prior forcing shutdown
ServiceDiscoveryURL *url.URL
BlockExecutionTimeout time.Duration
TmpDir string

StateStoreURL string
StateStoreDefaultTag string
Expand Down Expand Up @@ -156,6 +168,10 @@ func (a *Tier1App) Run() error {
opts = append(opts, service.WithBlockExecutionTimeout(a.config.BlockExecutionTimeout))
}

if a.config.TmpDir != "" {
wazero.SetTempDir(a.config.TmpDir)
}

var wasmModules map[string]string
if a.config.WASMExtensions != nil {
wasmModules = a.config.WASMExtensions.Params()
Expand Down Expand Up @@ -197,6 +213,16 @@ func (a *Tier1App) Run() error {
})

go func() {
var infoServer ssconnect.EndpointInfoHandler
if a.modules.InfoServer != nil {
a.logger.Info("waiting until info server is ready")
infoServer = &InfoServerWrapper{a.modules.InfoServer}
if err := a.modules.InfoServer.Init(context.Background(), forkableHub, mergedBlocksStore, oneBlocksStore, a.logger); err != nil {
a.Shutdown(fmt.Errorf("cannot initialize info server: %w", err))
return
}
}

if withLive {
a.logger.Info("waiting until hub is real-time synced")
select {
Expand All @@ -210,7 +236,7 @@ func (a *Tier1App) Run() error {
a.logger.Info("launching gRPC server", zap.Bool("live_support", withLive))
a.isReady.CompareAndSwap(false, true)

err := service.ListenTier1(a.config.GRPCListenAddr, svc, a.modules.Authenticator, a.logger, a.HealthCheck)
err := service.ListenTier1(a.config.GRPCListenAddr, svc, infoServer, a.modules.Authenticator, a.logger, a.HealthCheck)
a.Shutdown(err)
}()

Expand Down Expand Up @@ -243,3 +269,18 @@ func (a *Tier1App) IsReady(ctx context.Context) bool {
func (config *Tier1Config) Validate() error {
return nil
}

var _ pbsubstreamsrpcconnect.EndpointInfoHandler = (*InfoServerWrapper)(nil)

type InfoServerWrapper struct {
rpcInfoServer InfoServer
}

// Info implements pbsubstreamsrpcconnect.EndpointInfoHandler.
func (i *InfoServerWrapper) Info(ctx context.Context, req *connect.Request[pbfirehose.InfoRequest]) (*connect.Response[pbfirehose.InfoResponse], error) {
resp, err := i.rpcInfoServer.Info(ctx, req.Msg)
if err != nil {
return nil, err
}
return connect.NewResponse(resp), nil
}
5 changes: 5 additions & 0 deletions app/tier2.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/streamingfast/substreams/pipeline"
"github.com/streamingfast/substreams/service"
"github.com/streamingfast/substreams/wasm"
"github.com/streamingfast/substreams/wasm/wazero"
"go.uber.org/atomic"
"go.uber.org/zap"
)
Expand All @@ -26,6 +27,7 @@ type Tier2Config struct {
MaximumConcurrentRequests uint64
WASMExtensions wasm.WASMExtensioner
BlockExecutionTimeout time.Duration
TmpDir string

Tracing bool
}
Expand Down Expand Up @@ -80,6 +82,9 @@ func (a *Tier2App) Run() error {

opts = append(opts, service.WithReadinessFunc(a.setReadiness))

if a.config.TmpDir != "" {
wazero.SetTempDir(a.config.TmpDir)
}
if a.config.WASMExtensions != nil {
opts = append(opts, service.WithWASMExtensioner(a.config.WASMExtensions))
}
Expand Down
9 changes: 7 additions & 2 deletions docs/release-notes/change-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## Unreleased

### Server
* Add `sf.substreams.rpc.v2.EndpointInfo/Info` endpoint (if the infoserver is given as a module, i.e. from firehose-core)
* Add an execution timeout of 3 minutes per block by default (can be overriden in tier1/tier2 Configs) -- this is useful when an external (eth_call) is stuck on a forked block hash.
* Revert 'initialBlocks' changes from v1.9.1 because a 'changing module hash' causes more trouble.
* Wazero: bump v1.8.0 and activate caching of precompiled wasm modules in `/tmp/wazero` to decrease compilation time

### Client
* Add `substreams auth` command, to authenticate via `thegraph.market` and to get a dev API Key.
* Rename `--discovery-endpoint` into `codegen-endpoint` in `substreams init` command.
* Add `substreams codegen subgraph` command that takes a substreams `module` and an `spkg` and that generates a simple `subgraph` from the `module` output.
* On `substreams init` command, if flag `--state-file` is provided, the state file is used by default for project generation.
* In `substreams init` command, the state file is named using a `Date format` and not using `Unix` anymore.
* Added an execution timeout of 3 minutes per block by default (can be overriden in tier1/tier2 Configs) -- this is useful when an external (eth_call) is stuck on a forked block hash.
* Tools->prometheus: added the possibility to override the start-block on an endpoint
* Revert 'initialBlocks' changes from v1.9.1 because a 'changing module hash' causes more trouble.

## v1.9.3

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/streamingfast/dgrpc v0.0.0-20240219152146-57bb131c39ca
github.com/streamingfast/dstore v0.1.1-0.20240311181234-470a7a84936f
github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091
github.com/streamingfast/pbgo v0.0.6-0.20231120172814-537d034aad5e
github.com/streamingfast/pbgo v0.0.6-0.20240823134334-812f6a16c5cb
github.com/stretchr/testify v1.8.4
github.com/yourbasic/graph v0.0.0-20210606180040-8ecfec1c2869
go.uber.org/zap v1.26.0
Expand Down Expand Up @@ -64,7 +64,7 @@ require (
github.com/streamingfast/substreams-sdk-go v0.0.0-20240110154316-5fb21a7a330b
github.com/streamingfast/substreams-sink-sql v1.0.1-0.20231127153906-acf5f3e34330
github.com/test-go/testify v1.1.4
github.com/tetratelabs/wazero v1.7.1
github.com/tetratelabs/wazero v1.8.0
github.com/tidwall/pretty v1.2.1
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0
go.opentelemetry.io/otel v1.24.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,8 @@ github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091 h1:RN5mrigyi
github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091/go.mod h1:VlduQ80JcGJSargkRU4Sg9Xo63wZD/l8A5NC/Uo1/uU=
github.com/streamingfast/opaque v0.0.0-20210811180740-0c01d37ea308 h1:xlWSfi1BoPfsHtPb0VEHGUcAdBF208LUiFCwfaVPfLA=
github.com/streamingfast/opaque v0.0.0-20210811180740-0c01d37ea308/go.mod h1:K1p8Bj/wG34KJvYzPUqtzpndffmpkrVY11u2hkyxCWQ=
github.com/streamingfast/pbgo v0.0.6-0.20231120172814-537d034aad5e h1:8hoT2QUwh+YNgIcCPux9xd4u9XojHR8hbyAzz7rQuEM=
github.com/streamingfast/pbgo v0.0.6-0.20231120172814-537d034aad5e/go.mod h1:fZuijmeFrqxW2YnnXmGrkQpUTHx3eHCaJUKwdvXAYKM=
github.com/streamingfast/pbgo v0.0.6-0.20240823134334-812f6a16c5cb h1:Xqt4ned9ELmQMKcg7cFbm56MKG2gBjnE1M+2HObOs6w=
github.com/streamingfast/pbgo v0.0.6-0.20240823134334-812f6a16c5cb/go.mod h1:eDQjKBYg9BWE2BTaV3UZeLZ5xw05+ywA9RCFTmM1w5Y=
github.com/streamingfast/protoreflect v0.0.0-20231205191344-4b629d20ce8d h1:33VIARqUqBUKXJcuQoOS1rVSms54tgxhhNCmrLptpLg=
github.com/streamingfast/protoreflect v0.0.0-20231205191344-4b629d20ce8d/go.mod h1:aBJivEdekmFWYSQ29EE/fN9IanJWJXbtjy3ky0XD/jE=
github.com/streamingfast/sf-tracing v0.0.0-20240430173521-888827872b90 h1:94HllkX4ttYVilo8ZJv05b5z8JiMmqBvv4+Jdgk/+2A=
Expand Down Expand Up @@ -587,8 +587,8 @@ github.com/teris-io/shortid v0.0.0-20171029131806-771a37caa5cf h1:Z2X3Os7oRzpdJ7
github.com/teris-io/shortid v0.0.0-20171029131806-771a37caa5cf/go.mod h1:M8agBzgqHIhgj7wEn9/0hJUZcrvt9VY+Ln+S1I5Mha0=
github.com/test-go/testify v1.1.4 h1:Tf9lntrKUMHiXQ07qBScBTSA0dhYQlu83hswqelv1iE=
github.com/test-go/testify v1.1.4/go.mod h1:rH7cfJo/47vWGdi4GPj16x3/t1xGOj2YxzmNQzk2ghU=
github.com/tetratelabs/wazero v1.7.1 h1:QtSfd6KLc41DIMpDYlJdoMc6k7QTN246DM2+n2Y/Dx8=
github.com/tetratelabs/wazero v1.7.1/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y=
github.com/tetratelabs/wazero v1.8.0 h1:iEKu0d4c2Pd+QSRieYbnQC9yiFlMS9D+Jr0LsRmcF4g=
github.com/tetratelabs/wazero v1.8.0/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs=
github.com/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo=
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
Expand Down
6 changes: 3 additions & 3 deletions pb/sf/substreams/index/v1/keys.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions pb/sf/substreams/intern/v2/deltas.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions pb/sf/substreams/intern/v2/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ea8d22e

Please sign in to comment.