Skip to content

feat: add --limits flag to cre workflow simulate#293

Open
wentzeld wants to merge 9 commits intomainfrom
add/simulatorlimits
Open

feat: add --limits flag to cre workflow simulate#293
wentzeld wants to merge 9 commits intomainfrom
add/simulatorlimits

Conversation

@wentzeld
Copy link
Contributor

Summary

  • Adds --limits flag (default: enabled) to enforce production-equivalent limits during simulation
  • Wraps HTTP, ConfHTTP, Consensus, and EVM chain capabilities with limit-enforcing wrappers
  • Adds WASM binary size pre-flight check
  • Adds cre workflow limits export command to dump default limits JSON
  • Supports custom limits via --limits ./custom.json and opt-out via --limits none

Test plan

  • cre workflow simulate with --limits default passes for workflows within limits
  • Oversized HTTP request body fails with ResourceExhausted error
  • Oversized HTTP response fails with ResourceExhausted error
  • Oversized confidential HTTP request fails with ResourceExhausted error
  • Oversized consensus observation fails with ResourceExhausted error
  • --limits none disables all limit enforcement
  • cre workflow limits export outputs valid JSON
  • go test ./cmd/workflow/simulate/... passes

tarcisiozf
tarcisiozf previously approved these changes Mar 9, 2026
@wentzeld wentzeld marked this pull request as ready for review March 10, 2026 13:51
@wentzeld wentzeld requested a review from a team as a code owner March 10, 2026 13:51
@tarcisiozf tarcisiozf force-pushed the add/simulatorlimits branch from 24c07be to 33f71d1 Compare March 17, 2026 17:11
"github.com/smartcontractkit/cre-cli/internal/runtime"
)

func New(runtimeContext *runtime.Context) *cobra.Command {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the runtimeContext used in this command?

compressedLimit := simLimits.WASMCompressedBinarySize()
if compressedLimit > 0 {
var buf bytes.Buffer
gz := gzip.NewWriter(&buf)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual deploy path uses brotli compression but this uses gzip. This will lead to quite drastically inaccurate results?

// ResolveLimits resolves a --limits flag value to SimulationLimits.
// Returns nil if limitsFlag is "none" (no limits enforcement).
func ResolveLimits(limitsFlag string) (*SimulationLimits, error) {
if limitsFlag == "" || limitsFlag == "none" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is an edge case here where if you call --limits flag with an empty space it silently vanishes?

@@ -0,0 +1,284 @@
package simulate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add some unit tests for this?

@@ -0,0 +1,176 @@
package simulate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for unit tests

// Apply simulation limits to engine-level settings when --limits is set
if simLimits != nil {
applyEngineLimits(cfg, simLimits)
// Re-apply allow-all chains since applyEngineLimits does not touch ChainAllowed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand what we are reapplying here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants