Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seperate sdk from workflow to as part of an effort to shrink the WASM binary size #765

Merged
merged 37 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2b3c38d
Seperate sdk from workflow to as part of an effort to shrink the WASM…
nolag Aug 30, 2024
792f3d1
Merge branch 'main' into rtinianov_issolate_builders
nolag Sep 11, 2024
7ccbaea
Remove leftover generated file
nolag Sep 11, 2024
a4f3ce7
No two sdk packages
nolag Sep 11, 2024
e1c96c5
Merge branch 'main' into rtinianov_issolate_builders
nolag Sep 12, 2024
ed24119
make generate
jmank88 Sep 12, 2024
0c49348
make generate w/ go1.22.7
jmank88 Sep 12, 2024
3345669
make generate w/ explicit 1.22.7
jmank88 Sep 12, 2024
ba24a28
Attempting from my laptop with latest
nolag Sep 12, 2024
40150a5
Add env call to see if something is different that causes a different…
nolag Sep 12, 2024
0869cdd
try to line environment variables up better
nolag Sep 12, 2024
09f6f02
Attempt to clear CGO flags, except ffile-prefix-map
nolag Sep 12, 2024
7f2e8c4
more explicit CGO flags...
nolag Sep 13, 2024
ed80ba2
add trimp path and remove build id from
nolag Sep 13, 2024
87a7ec2
Copy flags from discord, user suggested that they make the build repr…
nolag Sep 13, 2024
dc42fd6
always build from ./...?
nolag Sep 13, 2024
0e9d1ff
Don't rely on embed
nolag Sep 13, 2024
03c9d66
try module
nolag Sep 14, 2024
9a4b240
Closer to reprodcible...
nolag Sep 14, 2024
da56bea
Attempt new flags
nolag Sep 15, 2024
4e9d6ac
Update go.mod to use the same version of go as the shell command
nolag Sep 15, 2024
7658247
Force rebuid of the WASM with a command that seems to be reproducible
nolag Sep 15, 2024
103fe73
add shasum to see if it's really different
nolag Sep 15, 2024
01d487f
Try using full directory in makefile
nolag Sep 15, 2024
d583ce2
Attempt to generate after mockery, maybe somehow it changes the sum...
nolag Sep 15, 2024
642871b
reproducible builds for real
nolag Sep 15, 2024
92648bb
gen last after
nolag Sep 15, 2024
ed0d796
Really reproducible
nolag Sep 15, 2024
caeafd8
Generate all deps first...
nolag Sep 15, 2024
ee9d173
Submod
nolag Sep 15, 2024
e4c4849
Ignore wasm file
nolag Sep 15, 2024
bdb9095
fix remove other mod
nolag Sep 15, 2024
b8252eb
Merge branch 'main' into rtinianov_issolate_builders
nolag Sep 16, 2024
f5128de
ignore monitoring in wasm builds
nolag Sep 16, 2024
5c2ce56
Merge branch 'main' into rtinianov_issolate_builders
nolag Sep 16, 2024
6714ecb
test builds the wasm
nolag Sep 16, 2024
49e77d3
Fix bad merge conflict resolution
nolag Sep 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ rm-mocked:
rm-builders:
# not sure why, but go.tmpl is matched when run in makefile but not when run in the commandline.
grep -rl "^// Code generated by github.com/smartcontractkit/chainlink-common/pkg/capabilities/cli" | grep .go$ | grep -v go.tmpl$ | xargs -r rm
# test wasm file should be removed as well
rm -f ./pkg/workflows/wasm/host/test/cmd/testmodule.wasm

.PHONY: generate
generate: mockery install-protoc gomods
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/smartcontractkit/chainlink-common

go 1.22

toolchain go1.22.5
toolchain go1.22.7

require (
github.com/atombender/go-jsonschema v0.16.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

package {{.Package}}test
import (
"github.com/smartcontractkit/chainlink-common/pkg/workflows/testutils"
"github.com/smartcontractkit/chainlink-common/pkg/workflows/sdk/testutils"
{{- if not (and (.RootType.Ref) (and .Input .Input.Ref)) }}
"{{.FullPackage}}"
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
{{- if not (.CapabilityType|IsCommon) }}
"github.com/smartcontractkit/chainlink-common/pkg/capabilities"
{{- end }}
"github.com/smartcontractkit/chainlink-common/pkg/workflows"
"github.com/smartcontractkit/chainlink-common/pkg/workflows/sdk"

{{- range .ExtraImports }}
{{.}}
Expand All @@ -14,12 +14,12 @@ import (
{{ if .Config.Ref }}type {{.Config.Name}} {{.Config.Ref}} {{ end }}

{{- if not (.CapabilityType|IsCommon) }}
func (cfg {{.Config.Name}}) New(w *workflows.WorkflowSpecFactory, {{- if not .ID }}id string,{{- end }} {{- if and (ne .CapabilityType "target") (ne .CapabilityType "trigger")}}ref string,{{- end }}{{- if .Input }} input {{InputAfterCapability}}{{- end }}) {{- if ne .CapabilityType "target"}}{{- if eq .RootNumSlice 0}}{{.RootType.Name}}Cap{{- else }}workflows.CapDefinition[{{Repeat "[]" .RootNumSlice}}{{.RootType.Name}}]{{- end }}{{- end }} {
func (cfg {{.Config.Name}}) New(w *sdk.WorkflowSpecFactory, {{- if not .ID }}id string,{{- end }} {{- if and (ne .CapabilityType "target") (ne .CapabilityType "trigger")}}ref string,{{- end }}{{- if .Input }} input {{InputAfterCapability}}{{- end }}) {{- if ne .CapabilityType "target"}}{{- if eq .RootNumSlice 0}}{{.RootType.Name}}Cap{{- else }}sdk.CapDefinition[{{Repeat "[]" .RootNumSlice}}{{.RootType.Name}}]{{- end }}{{- end }} {
{{ if eq .CapabilityType "trigger" }} ref := "trigger" {{- end }}
def := workflows.StepDefinition{
def := sdk.StepDefinition{
ID: {{- if .ID }} "{{.ID}}" {{- else }} id {{- end }},
{{- if ne .CapabilityType "target"}}Ref: ref, {{- end }}
Inputs: {{- if .Input }} input.ToSteps() {{- else }} workflows.StepInputs{} {{ end }},
Inputs: {{- if .Input }} input.ToSteps() {{- else }} sdk.StepInputs{} {{ end }},
Config: map[string]any{
{{- range $fieldName, $type := .Config.Outputs }}
"{{$type.ConfigName}}": cfg.{{$fieldName}},
Expand All @@ -29,7 +29,7 @@ func (cfg {{.Config.Name}}) New(w *workflows.WorkflowSpecFactory, {{- if not .ID
}


step := workflows.Step[{{- if eq .CapabilityType "target"}}struct{}{{- else }}{{Repeat "[]" .RootNumSlice}}{{.RootOutput}} {{- end}}]{Definition: def}
step := sdk.Step[{{- if eq .CapabilityType "target"}}struct{}{{- else }}{{Repeat "[]" .RootNumSlice}}{{.RootOutput}} {{- end}}]{Definition: def}
{{- if eq .CapabilityType "target" }}
step.AddTo(w)
{{- else if eq 0 .RootNumSlice }}
Expand All @@ -43,10 +43,10 @@ func (cfg {{.Config.Name}}) New(w *workflows.WorkflowSpecFactory, {{- if not .ID
{{ range $key, $value := .Types }}
{{- if .Outputs }}
type {{$key}}Cap interface {
workflows.CapDefinition[{{ $key }}]
sdk.CapDefinition[{{ $key }}]
{{- range $fieldName, $type := .Outputs }}
{{- if or $type.IsPrimitive (ne $type.NumSlice 0) }}
{{$fieldName}}() workflows.CapDefinition[{{Repeat "[]" $type.NumSlice}}{{ $type.Type }}]
{{$fieldName}}() sdk.CapDefinition[{{Repeat "[]" $type.NumSlice}}{{ $type.Type }}]
{{- else }}
{{$fieldName}}() {{ $type.Type }}Cap
{{- end }}
Expand All @@ -56,42 +56,42 @@ type {{$key}}Cap interface {

{{ if ne $.CapabilityType "target" }}
// {{$key}}CapFromStep should only be called from generated code to assure type safety
func {{$key}}CapFromStep(w *workflows.WorkflowSpecFactory, step workflows.Step[{{$key}}]) {{$key}}Cap {
func {{$key}}CapFromStep(w *sdk.WorkflowSpecFactory, step sdk.Step[{{$key}}]) {{$key}}Cap {
raw := step.AddTo(w)
return &{{$key|LowerFirst}}{CapDefinition: raw}
}
{{ end }}

type {{$key|LowerFirst}} struct {
workflows.CapDefinition[{{ $key }}]
sdk.CapDefinition[{{ $key }}]
}

func (*{{$key|LowerFirst}}) private() {}

{{- range $fieldName, $type := .Outputs }}
{{- if or $type.IsPrimitive (ne $type.NumSlice 0) }}
func (c *{{$key|LowerFirst}}) {{$fieldName}}() workflows.CapDefinition[{{Repeat "[]" $type.NumSlice}}{{ $type.Type }}] {
return workflows.AccessField[{{$value.Name}}, {{Repeat "[]" $type.NumSlice}}{{$type.Type}}](c.CapDefinition, "{{$type.ConfigName}}")
func (c *{{$key|LowerFirst}}) {{$fieldName}}() sdk.CapDefinition[{{Repeat "[]" $type.NumSlice}}{{ $type.Type }}] {
return sdk.AccessField[{{$value.Name}}, {{Repeat "[]" $type.NumSlice}}{{$type.Type}}](c.CapDefinition, "{{$type.ConfigName}}")
}
{{- else }}
func (c *{{$key|LowerFirst}}) {{$fieldName}}() {{ $type.Type }}Cap {
{{- if $type.Type|HasOutputs }}
return &{{ $type.Type | LowerFirst }}{ CapDefinition: workflows.AccessField[{{$value.Name}}, {{$type.Type}}](c.CapDefinition, "{{$type.ConfigName}}")}
return &{{ $type.Type | LowerFirst }}{ CapDefinition: sdk.AccessField[{{$value.Name}}, {{$type.Type}}](c.CapDefinition, "{{$type.ConfigName}}")}
{{- else }}
return {{ $type.Type }}Cap(workflows.AccessField[{{$value.Name}}, {{$type.Type}}](c.CapDefinition, "{{$type.ConfigName}}"))
return {{ $type.Type }}Cap(sdk.AccessField[{{$value.Name}}, {{$type.Type}}](c.CapDefinition, "{{$type.ConfigName}}"))
{{- end }}
}
{{- end }}
{{- end }}

func New{{$key}}FromFields({{- range $fieldName, $type := .Outputs }}
{{- if or $type.IsPrimitive (ne $type.NumSlice 0) }}
{{$fieldName|LowerFirst}} workflows.CapDefinition[{{Repeat "[]" $type.NumSlice}}{{ $type.Type }}],
{{$fieldName|LowerFirst}} sdk.CapDefinition[{{Repeat "[]" $type.NumSlice}}{{ $type.Type }}],
{{- else }}
{{$fieldName|LowerFirst}} {{ $type.Type }}Cap,
{{- end }} {{- end }}) {{$key}}Cap {
return &simple{{$key}}{
CapDefinition: workflows.ComponentCapDefinition[{{$value.Name}}]{ {{- range $fieldName, $type := .Outputs }}
CapDefinition: sdk.ComponentCapDefinition[{{$value.Name}}]{ {{- range $fieldName, $type := .Outputs }}
"{{$type.ConfigName}}": {{$fieldName|LowerFirst}}.Ref(),
{{- end }}
},
Expand All @@ -102,10 +102,10 @@ func New{{$key}}FromFields({{- range $fieldName, $type := .Outputs }}
}

type simple{{$key}} struct {
workflows.CapDefinition[{{ $key }}]
sdk.CapDefinition[{{ $key }}]
{{- range $fieldName, $type := .Outputs }}
{{- if or $type.IsPrimitive (ne $type.NumSlice 0) }}
{{$fieldName|LowerFirst}} workflows.CapDefinition[{{Repeat "[]" $type.NumSlice}}{{ $type.Type }}]
{{$fieldName|LowerFirst}} sdk.CapDefinition[{{Repeat "[]" $type.NumSlice}}{{ $type.Type }}]
{{- else }}
{{$fieldName|LowerFirst}} {{ $type.Type }}Cap
{{- end }}
Expand All @@ -114,7 +114,7 @@ type simple{{$key}} struct {

{{- range $fieldName, $type := .Outputs }}
{{- if or $type.IsPrimitive (ne $type.NumSlice 0) }}
func (c *simple{{$key}}) {{$fieldName}}() workflows.CapDefinition[{{Repeat "[]" $type.NumSlice}}{{ $type.Type }}] {
func (c *simple{{$key}}) {{$fieldName}}() sdk.CapDefinition[{{Repeat "[]" $type.NumSlice}}{{ $type.Type }}] {
{{- else }}
func (c *simple{{$key}}) {{$fieldName}}() {{ $type.Type }}Cap {
{{- end }}
Expand All @@ -124,7 +124,7 @@ func (c *simple{{$key}}) {{$fieldName}}() {{ $type.Type }}Cap {

func (c *simple{{$key}}) private() {}
{{- else }}
type {{$key}}Cap workflows.CapDefinition[{{ $key }}]
type {{$key}}Cap sdk.CapDefinition[{{ $key }}]
{{- end }}

{{ end }}
Expand All @@ -135,12 +135,12 @@ type {{InputAfterCapability}} = {{.Input.RefPkg}}.{{InputAfterCapability}}
{{- else }}
type {{InputAfterCapability}} struct {
{{- range $fieldName, $type := .Input.Outputs }}
{{$fieldName}} workflows.CapDefinition[{{Repeat "[]" $type.NumSlice}}{{ $type.Type }}]
{{$fieldName}} sdk.CapDefinition[{{Repeat "[]" $type.NumSlice}}{{ $type.Type }}]
{{- end }}
}

func (input {{InputAfterCapability}}) ToSteps() workflows.StepInputs {
return workflows.StepInputs{
func (input {{InputAfterCapability}}) ToSteps() sdk.StepInputs {
return sdk.StepInputs{
Mapping: map[string]any{
{{- range $fieldName, $type := .Input.Outputs }}
"{{$type.ConfigName}}": input.{{$fieldName}}.Ref(),
Expand Down
Loading
Loading