Skip to content

Commit

Permalink
checkpoint pre multi workflow type tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ettec committed Jan 23, 2025
1 parent e1fa917 commit 3bddabf
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.23.3
require (
github.com/andybalholm/brotli v1.1.1
github.com/atombender/go-jsonschema v0.16.1-0.20240916205339-a74cd4e2851c
github.com/bytecodealliance/wasmtime-go/v23 v23.0.0
github.com/bytecodealliance/wasmtime-go/v28 v28.0.0
github.com/confluentinc/confluent-kafka-go/v2 v2.3.0
github.com/dominikbraun/graph v0.23.0
github.com/fxamacker/cbor/v2 v2.5.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZ
github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/bytecodealliance/wasmtime-go/v23 v23.0.0 h1:NJvU4S8KEk1GnF6+FvlnzMD/8wXTj/mYJSG6Q4yu3Pw=
github.com/bytecodealliance/wasmtime-go/v23 v23.0.0/go.mod h1:5YIL+Ouiww2zpO7u+iZ1U1G5NvmwQYaXdmCZQGjQM0U=
github.com/bytecodealliance/wasmtime-go/v28 v28.0.0 h1:aBU8cexP2rPZ0Qz488kvn2NXvWZHL2aG1/+n7Iv+xGc=
github.com/bytecodealliance/wasmtime-go/v28 v28.0.0/go.mod h1:4OCU0xAW9ycwtX4nMF4zxwgJBJ5/0eMfJiHB0wAmkV4=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand Down
17 changes: 4 additions & 13 deletions pkg/workflows/wasm/host/module.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
package host

import (
"bytes"
"context"
"encoding/base64"
"encoding/binary"
"encoding/json"
"errors"
"fmt"
"io"
"math"

"strings"
"sync"
"time"

"github.com/andybalholm/brotli"
"github.com/bytecodealliance/wasmtime-go/v23"
"github.com/bytecodealliance/wasmtime-go/v28"
"google.golang.org/protobuf/proto"

"github.com/smartcontractkit/chainlink-common/pkg/custmsg"
Expand Down Expand Up @@ -181,16 +178,10 @@ func NewModule(modCfg *ModuleConfig, binary []byte, newWasmModule func(engine *w
cfg.CacheConfigLoadDefault()
cfg.SetCraneliftOptLevel(wasmtime.OptLevelSpeedAndSize)

engine := wasmtime.NewEngineWithConfig(cfg)
if !modCfg.IsUncompressed {
rdr := brotli.NewReader(bytes.NewBuffer(binary))
decompedBinary, err := io.ReadAll(rdr)
if err != nil {
return nil, fmt.Errorf("failed to decompress binary: %w", err)
}
// this is critical to ensure loading performance does not deteriorate
cfg.SetNativeUnwindInfo(false)

binary = decompedBinary
}
engine := wasmtime.NewEngineWithConfig(cfg)

mod, err := newWasmModule(engine, binary)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/workflows/wasm/host/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sync"
"testing"

"github.com/bytecodealliance/wasmtime-go/v23"
"github.com/bytecodealliance/wasmtime-go/v28"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
Expand Down
2 changes: 1 addition & 1 deletion pkg/workflows/wasm/host/wasip1.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"math/rand"
"time"

"github.com/bytecodealliance/wasmtime-go/v23"
"github.com/bytecodealliance/wasmtime-go/v28"
"github.com/jonboulle/clockwork"
)

Expand Down
4 changes: 3 additions & 1 deletion pkg/workflows/wasm/host/wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"errors"
"fmt"

"github.com/bytecodealliance/wasmtime-go/v23"
"github.com/bytecodealliance/wasmtime-go/v28"
"github.com/google/uuid"

"google.golang.org/protobuf/types/known/emptypb"
Expand All @@ -14,6 +14,8 @@ import (
wasmpb "github.com/smartcontractkit/chainlink-common/pkg/workflows/wasm/pb"
)

type WasmModuleFactoryFn func(engine *wasmtime.Engine, wasm []byte) (*wasmtime.Module, error)

func GetWorkflowSpec(ctx context.Context, modCfg *ModuleConfig, binary []byte,
newWasmModule func(engine *wasmtime.Engine, wasm []byte) (*wasmtime.Module, error), config []byte) (*sdk.WorkflowSpec, error) {
m, err := NewModule(modCfg, binary, newWasmModule, WithDeterminism())
Expand Down
2 changes: 1 addition & 1 deletion pkg/workflows/wasm/host/wasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"time"

"github.com/andybalholm/brotli"
"github.com/bytecodealliance/wasmtime-go/v23"
"github.com/bytecodealliance/wasmtime-go/v28"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down

0 comments on commit 3bddabf

Please sign in to comment.