Skip to content

Commit

Permalink
refactoring for wasm extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
colindickson committed Mar 26, 2024
1 parent e8e8522 commit 5977d3f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 41 deletions.
5 changes: 3 additions & 2 deletions chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
"runtime/debug"
"strings"

"github.com/streamingfast/substreams/wasm"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
pbbstream "github.com/streamingfast/bstream/pb/sf/bstream/v1"
"github.com/streamingfast/firehose-core/node-manager/mindreader"
"github.com/streamingfast/firehose-core/node-manager/operator"
"github.com/streamingfast/firehose-core/substreams"
"github.com/streamingfast/logging"
"go.uber.org/multierr"
"go.uber.org/zap"
Expand Down Expand Up @@ -150,7 +151,7 @@ type Chain[B Block] struct {
//
BlockEncoder BlockEncoder

RegisterSubstreamsExtensions func(chain *Chain[B]) ([]substreams.Extension, error)
RegisterSubstreamsExtensions func() (wasm.WASMExtensioner, error)
}

type ToolsConfig[B Block] struct {
Expand Down
23 changes: 0 additions & 23 deletions cmd/apps/substreams_common.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package apps

import (
"fmt"
"sync"

"github.com/spf13/cobra"
firecore "github.com/streamingfast/firehose-core"
"github.com/streamingfast/substreams/pipeline"
"github.com/streamingfast/substreams/wasm"
)

var registerSSOnce sync.Once
Expand All @@ -19,22 +15,3 @@ func registerCommonSubstreamsFlags(cmd *cobra.Command) {
cmd.Flags().String("substreams-state-store-default-tag", "", "If non-empty, will be appended to {substreams-state-store-url} (ex: 'v1'). Can be overriden per-request with 'X-Sf-Substreams-Cache-Tag' header")
})
}

func getSubstreamsExtensions[B firecore.Block](chain *firecore.Chain[B]) ([]wasm.WASMExtensioner, []pipeline.PipelineOptioner, error) {
var wasmExtensions []wasm.WASMExtensioner
var pipelineOptions []pipeline.PipelineOptioner

if chain.RegisterSubstreamsExtensions != nil {
extensions, err := chain.RegisterSubstreamsExtensions(chain)
if err != nil {
return nil, nil, fmt.Errorf("register substreams extensions failed: %w", err)
}

for _, extension := range extensions {
wasmExtensions = append(wasmExtensions, extension.WASMExtensioner)
pipelineOptions = append(pipelineOptions, extension.PipelineOptioner)
}
}

return wasmExtensions, pipelineOptions, nil
}
5 changes: 2 additions & 3 deletions cmd/apps/substreams_tier1.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func RegisterSubstreamsTier1App[B firecore.Block](chain *firecore.Chain[B], root
}
}

wasmExtensions, pipelineOptioner, err := getSubstreamsExtensions(chain)
wasmExtensions, err := chain.RegisterSubstreamsExtensions()
if err != nil {
return nil, fmt.Errorf("substreams extensions: %w", err)
}
Expand All @@ -117,8 +117,7 @@ func RegisterSubstreamsTier1App[B firecore.Block](chain *firecore.Chain[B], root
SubrequestsInsecure: subrequestsInsecure,
SubrequestsPlaintext: subrequestsPlaintext,

WASMExtensions: wasmExtensions,
PipelineOptions: pipelineOptioner,
WASMExtensions: wasmExtensions,

Tracing: tracing,

Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module github.com/streamingfast/firehose-core

go 1.22

replace github.com/streamingfast/substreams => github.com/streamingfast/substreams v1.4.1-0.20240326144332-9f8e91e85d39

require (
buf.build/gen/go/bufbuild/reflect/connectrpc/go v1.12.0-20230822193137-310c9c4845dd.1
buf.build/gen/go/bufbuild/reflect/protocolbuffers/go v1.31.0-20230822193137-310c9c4845dd.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,8 @@ github.com/streamingfast/shutter v1.5.0 h1:NpzDYzj0HVpSiDJVO/FFSL6QIK/YKOxY0gJAt
github.com/streamingfast/shutter v1.5.0/go.mod h1:B/T6efqdeMGbGwjzPS1ToXzYZI4kDzI5/u4I+7qbjY8=
github.com/streamingfast/snapshotter v0.0.0-20230316190750-5bcadfde44d0 h1:Y15G1Z4fpEdm2b+/70owI7TLuXadlqBtGM7rk4Hxrzk=
github.com/streamingfast/snapshotter v0.0.0-20230316190750-5bcadfde44d0/go.mod h1:/Rnz2TJvaShjUct0scZ9kKV2Jr9/+KBAoWy4UMYxgv4=
github.com/streamingfast/substreams v1.4.1-0.20240326143310-a4878081f44c h1:rr6W9hiYdC+Jf4KcW1zggAU50jZc01dYtNpUlyMDnaY=
github.com/streamingfast/substreams v1.4.1-0.20240326143310-a4878081f44c/go.mod h1:tS03mbQ14PcuqmQCKvj82yENHaMl2xKxUBvWHJT06QQ=
github.com/streamingfast/substreams v1.4.1-0.20240326144332-9f8e91e85d39 h1:pIcLENGVftM7G7KZ+dH/fIZGJ/fLDiSKn4mmS34u9jw=
github.com/streamingfast/substreams v1.4.1-0.20240326144332-9f8e91e85d39/go.mod h1:tS03mbQ14PcuqmQCKvj82yENHaMl2xKxUBvWHJT06QQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
Expand Down
11 changes: 0 additions & 11 deletions substreams/extentions.go

This file was deleted.

0 comments on commit 5977d3f

Please sign in to comment.