diff --git a/pkg/settings/cresettings/defaults.json b/pkg/settings/cresettings/defaults.json index 3355738b6..76c4e7e99 100644 --- a/pkg/settings/cresettings/defaults.json +++ b/pkg/settings/cresettings/defaults.json @@ -30,7 +30,7 @@ "ExecutionResponseLimit": "100kb", "WASMExecutionTimeout": "1m0s", "WASMMemoryLimit": "100mb", - "WASMBinarySizeLimit": "30mb", + "WASMBinarySizeLimit": "100mb", "WASMCompressedBinarySizeLimit": "20mb", "WASMConfigSizeLimit": "30mb", "WASMSecretsSizeLimit": "30mb", diff --git a/pkg/settings/cresettings/defaults.toml b/pkg/settings/cresettings/defaults.toml index d09f6bad4..b9c7c0355 100644 --- a/pkg/settings/cresettings/defaults.toml +++ b/pkg/settings/cresettings/defaults.toml @@ -30,7 +30,7 @@ ExecutionTimeout = '10m0s' ExecutionResponseLimit = '100kb' WASMExecutionTimeout = '1m0s' WASMMemoryLimit = '100mb' -WASMBinarySizeLimit = '30mb' +WASMBinarySizeLimit = '100mb' WASMCompressedBinarySizeLimit = '20mb' WASMConfigSizeLimit = '30mb' WASMSecretsSizeLimit = '30mb' diff --git a/pkg/settings/cresettings/settings.go b/pkg/settings/cresettings/settings.go index 67830feba..3f10895e4 100644 --- a/pkg/settings/cresettings/settings.go +++ b/pkg/settings/cresettings/settings.go @@ -76,7 +76,7 @@ var Default = Schema{ ExecutionResponseLimit: Size(100 * config.KByte), WASMExecutionTimeout: Duration(60 * time.Second), WASMMemoryLimit: Size(100 * config.MByte), - WASMBinarySizeLimit: Size(30 * config.MByte), + WASMBinarySizeLimit: Size(100 * config.MByte), WASMCompressedBinarySizeLimit: Size(20 * config.MByte), WASMConfigSizeLimit: Size(30 * config.MByte), WASMSecretsSizeLimit: Size(30 * config.MByte), diff --git a/pkg/workflows/wasm/host/module.go b/pkg/workflows/wasm/host/module.go index 0b01d01ce..73aad9f09 100644 --- a/pkg/workflows/wasm/host/module.go +++ b/pkg/workflows/wasm/host/module.go @@ -251,7 +251,7 @@ func NewModule(ctx context.Context, modCfg *ModuleConfig, binary []byte, opts .. // this is to prevent decompression bombs if err := modCfg.MaxCompressedBinaryLimiter.Check(ctx, config.SizeOf(binary)); err != nil { if errors.Is(err, limits.ErrorBoundLimited[config.Size]{}) { - return nil, fmt.Errorf("compressed binary size exceeds the maximum allowed size of %d bytes: %w", modCfg.MaxCompressedBinarySize, err) + return nil, fmt.Errorf("compressed binary size exceeds the maximum allowed size: %w", err) } return nil, fmt.Errorf("failed to check compressed binary size limit: %w", err) } @@ -273,7 +273,7 @@ func NewModule(ctx context.Context, modCfg *ModuleConfig, binary []byte, opts .. // The Read() method will return io.EOF, and ReadAll will gracefully handle it and return nil. if err := modCfg.MaxDecompressedBinaryLimiter.Check(ctx, config.SizeOf(binary)); err != nil { if errors.Is(err, limits.ErrorBoundLimited[config.Size]{}) { - return nil, fmt.Errorf("decompressed binary size reached the maximum allowed size of %d bytes: %w", modCfg.MaxDecompressedBinarySize, err) + return nil, fmt.Errorf("decompressed binary size reached the maximum allowed size: %w", err) } return nil, fmt.Errorf("failed to check decompressed binary size limit: %w", err) } diff --git a/pkg/workflows/wasm/host/wasm_test.go b/pkg/workflows/wasm/host/wasm_test.go index 4255b2c32..8f13638f1 100644 --- a/pkg/workflows/wasm/host/wasm_test.go +++ b/pkg/workflows/wasm/host/wasm_test.go @@ -21,7 +21,9 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb" capabilitiespb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb" + "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink-common/pkg/settings/limits" wasmpb "github.com/smartcontractkit/chainlink-common/pkg/workflows/wasm/pb" valuespb "github.com/smartcontractkit/chainlink-protos/cre/go/values/pb" ) @@ -943,8 +945,10 @@ func TestModule_CompressedBinarySize(t *testing.T) { require.NoError(t, bwr.Close()) _, err = NewModule(t.Context(), &ModuleConfig{IsUncompressed: false, Logger: logger.Test(t)}, binary) - default10mbLimit := fmt.Sprintf("binary size exceeds the maximum allowed size of %d bytes", defaultMaxCompressedBinarySize) - require.ErrorContains(t, err, default10mbLimit) + require.ErrorContains(t, err, "binary size exceeds the maximum allowed size") + var limitErr limits.ErrorBoundLimited[config.Size] + require.ErrorAs(t, err, &limitErr) + assert.Equal(t, defaultMaxCompressedBinarySize, int(limitErr.Limit)) }) t.Run("compressed binary size is bigger than the custom limit", func(t *testing.T) { @@ -958,8 +962,10 @@ func TestModule_CompressedBinarySize(t *testing.T) { require.NoError(t, bwr.Close()) _, err = NewModule(t.Context(), &ModuleConfig{IsUncompressed: false, MaxCompressedBinarySize: customMaxCompressedBinarySize, Logger: logger.Test(t)}, binary) - default10mbLimit := fmt.Sprintf("binary size exceeds the maximum allowed size of %d bytes", customMaxCompressedBinarySize) - require.ErrorContains(t, err, default10mbLimit) + require.ErrorContains(t, err, "binary size exceeds the maximum allowed size") + var limitErr limits.ErrorBoundLimited[config.Size] + require.ErrorAs(t, err, &limitErr) + assert.Equal(t, customMaxCompressedBinarySize, uint64(limitErr.Limit)) }) } @@ -979,8 +985,10 @@ func TestModule_DecompressedBinarySize(t *testing.T) { t.Run("decompressed binary size is bigger than the limit", func(t *testing.T) { customDecompressedBinarySize := uint64(len(decompedBinary) - 1) _, err := NewModule(t.Context(), &ModuleConfig{IsUncompressed: false, MaxDecompressedBinarySize: customDecompressedBinarySize, Logger: logger.Test(t)}, binary) - decompressedSizeExceeded := fmt.Sprintf("decompressed binary size reached the maximum allowed size of %d bytes", customDecompressedBinarySize) - require.ErrorContains(t, err, decompressedSizeExceeded) + require.ErrorContains(t, err, "decompressed binary size reached the maximum allowed size") + var limitErr limits.ErrorBoundLimited[config.Size] + require.ErrorAs(t, err, &limitErr) + assert.Equal(t, customDecompressedBinarySize, uint64(limitErr.Limit)) }) }