From a006291d264bbeb9e472651c2a6580d3e86a318b Mon Sep 17 00:00:00 2001 From: Vu Nguyen Hoang Date: Mon, 8 Jun 2026 16:15:52 +0700 Subject: [PATCH] remove request compiler options --- backend/README.md | 8 +-- backend/internal/httpapi/openapi.go | 18 ----- backend/internal/httpapi/openapi_test.go | 7 +- backend/internal/model/types.go | 14 ---- backend/internal/simulation/service.go | 33 ++------- backend/internal/simulation/service_test.go | 46 +++++++----- backend/internal/solidity/render.go | 72 ------------------- backend/internal/solidity/render_test.go | 70 ------------------ frontend/src/api/schemas.ts | 15 ---- frontend/src/api/types.ts | 1 - frontend/src/app/form.ts | 50 +------------ frontend/src/features/request/RequestForm.tsx | 43 ----------- frontend/tests/request-lookup.spec.ts | 11 +-- frontend/tests/simulation-ui.spec.ts | 8 ++- 14 files changed, 47 insertions(+), 349 deletions(-) delete mode 100644 backend/internal/solidity/render_test.go diff --git a/backend/README.md b/backend/README.md index 2b4a52f..5906250 100644 --- a/backend/README.md +++ b/backend/README.md @@ -158,12 +158,6 @@ Inside Docker, native project browsing is unavailable because the backend runs i "contractName": "MyStateOverride", "source": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\ncontract MyStateOverride { fallback() external {} }" }, - "compiler": { - "viaIR": true, - "optimize": true, - "optimizerRuns": 200, - "revertStrings": "default" - }, "decodeInternal": false, "sender": "0x0000000000000000000000000000000000000000", "target": "0x0000000000000000000000000000000000000000", @@ -184,7 +178,7 @@ to the final `forge-kyber test --json` command. `projectPath` is optional. When provided, the backend treats it as another Foundry project, runs `forge-kyber build src --root `, copies `contracts/test/SimulateTxRunner.t.sol` into a deterministic content-hash file under `/test/`, runs `forge-kyber test --json` against that copied test with `--root `, then removes the temporary test file after the last active run using it finishes. Relative paths are resolved against the backend repo root. Paths beginning with `~` are expanded to the backend process user's home directory before validation. -`compiler` is optional and maps to popular Forge compiler flags. Supported fields are `use`, `offline`, `noAutoDetect`, `viaIR`, `useLiteralContent`, `noMetadata`, `evmVersion`, `optimize`, `optimizerRuns`, and `revertStrings`. The backend only passes `use` and `evmVersion` when they are explicitly provided. The state override `forge-kyber inspect` compile and final `forge-kyber test` run default `viaIR` and `optimize` to `true`; external-project `forge-kyber build src` uses the target project's defaults unless compiler fields are explicitly set. +Compiler settings come from the selected Foundry project. The backend does not accept compiler options on the simulation request or add request-level compiler flags to `forge-kyber build`, `forge-kyber inspect`, or `forge-kyber test`. ## Tx Request diff --git a/backend/internal/httpapi/openapi.go b/backend/internal/httpapi/openapi.go index c2227d7..f1e317e 100644 --- a/backend/internal/httpapi/openapi.go +++ b/backend/internal/httpapi/openapi.go @@ -123,7 +123,6 @@ func registerOpenAPISchemas(schemas openapi3.Schemas) error { {"ERC20ApprovalOverride", model.ERC20ApprovalOverride{}}, {"ERC721ApprovalOverride", model.ERC721ApprovalOverride{}}, {"StateOverride", model.StateOverride{}}, - {"CompilerConfig", model.CompilerConfig{}}, {"SimulateResponse", model.SimulateResponse{}}, {"ERC20Transfer", model.ERC20Transfer{}}, {"BalanceAnalysis", model.BalanceAnalysis{}}, @@ -264,23 +263,6 @@ func enrichOpenAPISchemas(schemas openapi3.Schemas) { setPropertyExample(schemas, "ERC721ApprovalOverride", "spender", "0x0000000000000000000000000000000000000002") setPropertyExample(schemas, "StateOverride", "contractName", "MyStateOverride") - setPropertyDescription(schemas, "CompilerConfig", "use", "Maps to forge-kyber --use . Omitted unless explicitly provided.") - setPropertyDescription(schemas, "CompilerConfig", "offline", "Maps to --offline.") - setPropertyDescription(schemas, "CompilerConfig", "noAutoDetect", "Maps to --no-auto-detect.") - setPropertyDescription(schemas, "CompilerConfig", "viaIR", "Maps to --via-ir. Defaults to true for this backend.") - setPropertyDefault(schemas, "CompilerConfig", "viaIR", true) - setPropertyDescription(schemas, "CompilerConfig", "useLiteralContent", "Maps to --use-literal-content.") - setPropertyDescription(schemas, "CompilerConfig", "noMetadata", "Maps to --no-metadata.") - setPropertyDescription(schemas, "CompilerConfig", "evmVersion", "Maps to --evm-version . Omitted unless explicitly provided.") - setPropertyDescription(schemas, "CompilerConfig", "optimize", "Maps to --optimize. Defaults to true for this backend.") - setPropertyDefault(schemas, "CompilerConfig", "optimize", true) - setPropertyDescription(schemas, "CompilerConfig", "optimizerRuns", "Maps to --optimizer-runs .") - setPropertyMinMax(schemas, "CompilerConfig", "optimizerRuns", 0, 4294967295) - setPropertyExample(schemas, "CompilerConfig", "optimizerRuns", 200) - setPropertyDescription(schemas, "CompilerConfig", "revertStrings", "Maps to --revert-strings .") - setPropertyEnum(schemas, "CompilerConfig", "revertStrings", "default", "strip", "debug", "verboseDebug") - setPropertyExample(schemas, "CompilerConfig", "revertStrings", "default") - if schema := schemaValue(schemas, "Uint256"); schema != nil { schema.Type = &openapi3.Types{"string"} schema.Pattern = uint256Pattern diff --git a/backend/internal/httpapi/openapi_test.go b/backend/internal/httpapi/openapi_test.go index 23e49af..5b5fc94 100644 --- a/backend/internal/httpapi/openapi_test.go +++ b/backend/internal/httpapi/openapi_test.go @@ -61,8 +61,8 @@ func TestOpenAPIEndpoint(t *testing.T) { if !ok { t.Fatalf("missing schemas in spec: %#v", components) } - if _, ok := schemas["CompilerConfig"]; !ok { - t.Fatalf("missing CompilerConfig schema: %#v", schemas) + if _, ok := schemas["CompilerConfig"]; ok { + t.Fatalf("CompilerConfig should not be exposed: %#v", schemas) } if _, ok := schemas["SimulationRecord"]; !ok { t.Fatalf("missing SimulationRecord schema: %#v", schemas) @@ -81,6 +81,9 @@ func TestOpenAPIEndpoint(t *testing.T) { if _, ok := properties["projectSourceFiles"]; ok { t.Fatalf("projectSourceFiles should be managed by /projects/default/source, not /simulation: %#v", properties) } + if _, ok := properties["compiler"]; ok { + t.Fatalf("compiler options should follow project settings, not /simulation: %#v", properties) + } if _, ok := properties["decodeInternal"]; !ok { t.Fatalf("decodeInternal should be a request property: %#v", properties) } diff --git a/backend/internal/model/types.go b/backend/internal/model/types.go index d8f803d..43e3482 100644 --- a/backend/internal/model/types.go +++ b/backend/internal/model/types.go @@ -17,7 +17,6 @@ type SimulateRequest struct { ERC721ApprovalOverrides []ERC721ApprovalOverride `json:"erc721ApprovalOverrides,omitempty" validate:"dive"` StateOverride *StateOverride `json:"stateOverride,omitempty"` StateOverrideBytecode string `json:"stateOverrideBytecode,omitempty" validate:"hex_bytes"` - Compiler *CompilerConfig `json:"compiler,omitempty"` DecodeInternal bool `json:"decodeInternal"` Sender string `json:"sender" validate:"required,eth_address"` Target string `json:"target" validate:"required,eth_address"` @@ -79,19 +78,6 @@ type StateOverride struct { ContractName string `json:"contractName,omitempty"` } -type CompilerConfig struct { - Use string `json:"use,omitempty"` - Offline bool `json:"offline,omitempty"` - NoAutoDetect bool `json:"noAutoDetect,omitempty"` - ViaIR *bool `json:"viaIR,omitempty"` - UseLiteralContent bool `json:"useLiteralContent,omitempty"` - NoMetadata bool `json:"noMetadata,omitempty"` - EVMVersion string `json:"evmVersion,omitempty"` - Optimize *bool `json:"optimize,omitempty"` - OptimizerRuns *uint32 `json:"optimizerRuns,omitempty"` - RevertStrings string `json:"revertStrings,omitempty"` -} - type HealthResponse struct { OK bool `json:"ok"` Chains int `json:"chains"` diff --git a/backend/internal/simulation/service.go b/backend/internal/simulation/service.go index 162ec63..d3289dc 100644 --- a/backend/internal/simulation/service.go +++ b/backend/internal/simulation/service.go @@ -258,7 +258,7 @@ func (s *Service) Simulate(parent context.Context, req model.SimulateRequest) (m if execution.BuildSrc { slog.Info("forge build src started", "run_id", runID, "root", execution.Root) - buildResult := s.buildProjectSrc(ctx, execution, req.Compiler) + buildResult := s.buildProjectSrc(ctx, execution) logForgeResult(runID, "build project src", buildResult) if buildResult.Err != nil { status := populateForgeFailure(&resp, start, buildResult, rpcURL, req.Chain, "build project src", buildResult.Err) @@ -284,7 +284,7 @@ func (s *Service) Simulate(parent context.Context, req model.SimulateRequest) (m slog.Info("state override source written", "run_id", runID, "contract", contractName, "path", statePath) slog.Info("state override compile started", "run_id", runID, "root", execution.Root, "contract", contractName) - bytecode, compileResult, err := s.compileStateOverride(ctx, execution.Root, statePath, contractName, req.Compiler) + bytecode, compileResult, err := s.compileStateOverride(ctx, execution.Root, statePath, contractName) logForgeResult(runID, "compile state override", compileResult) if err != nil { status := populateForgeFailure(&resp, start, compileResult, rpcURL, req.Chain, "compile state override", err) @@ -322,8 +322,6 @@ func (s *Service) Simulate(parent context.Context, req model.SimulateRequest) (m if req.DecodeInternal { forgeArgs = append(forgeArgs, "--decode-internal") } - compilerArgs := solidity.ForgeCompilerArgs(req.Compiler) - forgeArgs = append(forgeArgs, compilerArgs...) if etherscanAPIKey != "" { forgeArgs = append(forgeArgs, "--etherscan-api-key", etherscanAPIKey) } @@ -336,7 +334,6 @@ func (s *Service) Simulate(parent context.Context, req model.SimulateRequest) (m "match_test", simulationTestName, "anvil_rpc", anvilRPCURL, "decode_internal", req.DecodeInternal, - "compiler_args", len(compilerArgs), ) result := s.forge.RunWithEnv(ctx, []string{inputPathEnvName + "=" + inputPath}, forgeArgs...) logForgeResult(runID, "forge test", result) @@ -530,10 +527,6 @@ func (s *Service) validateRequest(ctx context.Context, req *model.SimulateReques req.Data = normalizedData ensureSenderLabel(req) - if err := validateCompilerConfig(req.Compiler); err != nil { - return "", err - } - return rpcURL, nil } @@ -621,22 +614,6 @@ func pathSuffixes(value string) []string { return suffixes } -func validateCompilerConfig(config *model.CompilerConfig) error { - if config == nil { - return nil - } - - config.Use = strings.TrimSpace(config.Use) - config.EVMVersion = strings.TrimSpace(config.EVMVersion) - config.RevertStrings = strings.TrimSpace(config.RevertStrings) - switch config.RevertStrings { - case "", "default", "strip", "debug", "verboseDebug": - default: - return fmt.Errorf("compiler.revertStrings must be one of default, strip, debug, or verboseDebug") - } - return nil -} - func (s *Service) prepareFoundryExecution(req *model.SimulateRequest, runID string) (foundryExecution, error) { localRoot := filepath.Join(s.cfg.RepoRoot, localFoundryDir) localTestPath := filepath.Join(localRoot, filepath.FromSlash(localSimulationRelPath)) @@ -822,9 +799,8 @@ func (s *Service) releaseTestCopy(testPath string) { } } -func (s *Service) buildProjectSrc(ctx context.Context, execution foundryExecution, compiler *model.CompilerConfig) forge.Result { +func (s *Service) buildProjectSrc(ctx context.Context, execution foundryExecution) forge.Result { args := []string{"build", "src", "--root", execution.Root, "--color", "never"} - args = append(args, solidity.ForgeCompilerArgsExplicit(compiler)...) return s.forge.Run(ctx, args...) } @@ -888,14 +864,13 @@ func safeRunID(runID string) string { return strings.NewReplacer(".", "_", "-", "_").Replace(runID) } -func (s *Service) compileStateOverride(ctx context.Context, projectRoot string, sourcePath string, contractName string, compiler *model.CompilerConfig) (string, forge.Result, error) { +func (s *Service) compileStateOverride(ctx context.Context, projectRoot string, sourcePath string, contractName string) (string, forge.Result, error) { contractID, err := solidity.ContractIdentifier(projectRoot, sourcePath, contractName) if err != nil { return "", forge.Result{}, err } args := []string{"inspect", contractID, "bytecode", "--root", projectRoot, "--contracts", ".", "--color", "never"} - args = append(args, solidity.ForgeCompilerArgs(compiler)...) result := s.forge.Run(ctx, args...) if result.Err != nil { return "", result, result.Err diff --git a/backend/internal/simulation/service_test.go b/backend/internal/simulation/service_test.go index c9a9954..5d51f46 100644 --- a/backend/internal/simulation/service_test.go +++ b/backend/internal/simulation/service_test.go @@ -85,13 +85,6 @@ func TestSimulateWETHBalanceApprovalAndTransferFrom(t *testing.T) { Amount: model.Uint256(amount), }, }, - Compiler: &model.CompilerConfig{ - ViaIR: boolPtr(true), - Optimize: boolPtr(true), - OptimizerRuns: uint32Ptr(200), - EVMVersion: "cancun", - RevertStrings: "default", - }, DecodeInternal: true, Sender: spender, Target: wethAddress, @@ -443,8 +436,8 @@ func TestSimulateExternalProjectBuildsSrcCompilesOverrideAndRunsCopiedTest(t *te if !hasArgSequence(buildArgs, "build", "src") || !hasArgSequence(buildArgs, "--root", projectRoot) { t.Fatalf("unexpected build args: %#v", buildArgs) } - if containsArg(buildArgs, "--via-ir") { - t.Fatalf("build should use target project defaults unless request compiler fields are set: %#v", buildArgs) + if hasCompilerArg(buildArgs) { + t.Fatalf("build should use target project compiler settings: %#v", buildArgs) } inspectArgs := fake.calls[1] @@ -454,6 +447,9 @@ func TestSimulateExternalProjectBuildsSrcCompilesOverrideAndRunsCopiedTest(t *te !hasArgSequence(inspectArgs, "--root", projectRoot) { t.Fatalf("unexpected inspect args: %#v", inspectArgs) } + if hasCompilerArg(inspectArgs) { + t.Fatalf("inspect should use target project compiler settings: %#v", inspectArgs) + } testArgs := fake.calls[2] testHash := sha256.Sum256(testSource) @@ -471,6 +467,9 @@ func TestSimulateExternalProjectBuildsSrcCompilesOverrideAndRunsCopiedTest(t *te containsArg(testArgs, "--non-interactive") { t.Fatalf("unexpected test args: %#v", testArgs) } + if hasCompilerArg(testArgs) { + t.Fatalf("test should use target project compiler settings: %#v", testArgs) + } if _, ok := envValue(fake.envs[2], inputPathEnvName); !ok { t.Fatalf("forge test env missing input path: %#v", fake.envs) } @@ -1114,14 +1113,6 @@ func leftPadHex(value string, length int) string { return strings.Repeat("0", length-len(value)) + value } -func boolPtr(value bool) *bool { - return &value -} - -func uint32Ptr(value uint32) *uint32 { - return &value -} - func forgeJSONTrace() string { return forgeJSONTraceWithCall(true, "transfer") } @@ -1389,6 +1380,27 @@ func containsArg(args []string, want string) bool { return false } +func hasCompilerArg(args []string) bool { + compilerArgs := map[string]struct{}{ + "--evm-version": {}, + "--no-auto-detect": {}, + "--no-metadata": {}, + "--offline": {}, + "--optimizer-runs": {}, + "--revert-strings": {}, + "--use": {}, + "--use-literal-content": {}, + "--via-ir": {}, + } + for _, arg := range args { + _, ok := compilerArgs[arg] + if ok || strings.HasPrefix(arg, "--optimize") { + return true + } + } + return false +} + func hasEnvPrefix(env []string, prefix string) bool { _, ok := envValueByPrefix(env, prefix) return ok diff --git a/backend/internal/solidity/render.go b/backend/internal/solidity/render.go index d67b6b8..ebde926 100644 --- a/backend/internal/solidity/render.go +++ b/backend/internal/solidity/render.go @@ -5,8 +5,6 @@ import ( "path/filepath" "regexp" "strings" - - "foundry-tx-simulator/backend/internal/model" ) var ( @@ -17,76 +15,6 @@ var ( hexValuePattern = regexp.MustCompile(`0x[0-9a-fA-F]+`) ) -func ForgeCompilerArgs(config *model.CompilerConfig) []string { - return forgeCompilerArgs(config, true) -} - -func ForgeCompilerArgsExplicit(config *model.CompilerConfig) []string { - return forgeCompilerArgs(config, false) -} - -func forgeCompilerArgs(config *model.CompilerConfig, useDefaults bool) []string { - if useDefaults { - config = effectiveCompilerConfig(config) - } - if config == nil { - return nil - } - - args := make([]string, 0, 16) - if config.NoAutoDetect { - args = append(args, "--no-auto-detect") - } - if strings.TrimSpace(config.Use) != "" { - args = append(args, "--use", strings.TrimSpace(config.Use)) - } - if config.Offline { - args = append(args, "--offline") - } - if config.ViaIR != nil && *config.ViaIR { - args = append(args, "--via-ir") - } - if config.UseLiteralContent { - args = append(args, "--use-literal-content") - } - if config.NoMetadata { - args = append(args, "--no-metadata") - } - if strings.TrimSpace(config.EVMVersion) != "" { - args = append(args, "--evm-version", strings.TrimSpace(config.EVMVersion)) - } - if config.Optimize != nil { - args = append(args, "--optimize="+fmt.Sprintf("%t", *config.Optimize)) - } - if config.OptimizerRuns != nil { - args = append(args, "--optimizer-runs", fmt.Sprintf("%d", *config.OptimizerRuns)) - } - if strings.TrimSpace(config.RevertStrings) != "" { - args = append(args, "--revert-strings", strings.TrimSpace(config.RevertStrings)) - } - return args -} - -func effectiveCompilerConfig(config *model.CompilerConfig) *model.CompilerConfig { - viaIR := true - optimize := true - if config == nil { - return &model.CompilerConfig{ - ViaIR: &viaIR, - Optimize: &optimize, - } - } - - effective := *config - if effective.ViaIR == nil { - effective.ViaIR = &viaIR - } - if effective.Optimize == nil { - effective.Optimize = &optimize - } - return &effective -} - func ValidateAddress(field string, value string) error { if !addressPattern.MatchString(value) { return fmt.Errorf("%s must be a 20-byte hex address", field) diff --git a/backend/internal/solidity/render_test.go b/backend/internal/solidity/render_test.go deleted file mode 100644 index 5b20b0e..0000000 --- a/backend/internal/solidity/render_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package solidity - -import ( - "reflect" - "testing" - - "foundry-tx-simulator/backend/internal/model" -) - -func TestForgeCompilerArgsDefaultsToCurrentCompilePath(t *testing.T) { - got := ForgeCompilerArgs(nil) - want := []string{"--via-ir", "--optimize=true"} - if !reflect.DeepEqual(got, want) { - t.Fatalf("ForgeCompilerArgs(nil) = %#v, want %#v", got, want) - } -} - -func TestForgeCompilerArgsDoesNotDefaultSolcOrEVMVersion(t *testing.T) { - for name, got := range map[string][]string{ - "nil": ForgeCompilerArgs(nil), - "empty": ForgeCompilerArgs(&model.CompilerConfig{}), - } { - for _, arg := range got { - if arg == "--use" || arg == "--evm-version" { - t.Fatalf("%s config args include version flag %#v", name, got) - } - } - } -} - -func TestForgeCompilerArgsUsesRequestConfig(t *testing.T) { - viaIR := false - optimize := false - runs := uint32(10_000) - - got := ForgeCompilerArgs(&model.CompilerConfig{ - Use: "0.8.30", - Offline: true, - NoAutoDetect: true, - ViaIR: &viaIR, - UseLiteralContent: true, - NoMetadata: true, - EVMVersion: "cancun", - Optimize: &optimize, - OptimizerRuns: &runs, - RevertStrings: "debug", - }) - want := []string{ - "--no-auto-detect", - "--use", "0.8.30", - "--offline", - "--use-literal-content", - "--no-metadata", - "--evm-version", "cancun", - "--optimize=false", - "--optimizer-runs", "10000", - "--revert-strings", "debug", - } - if !reflect.DeepEqual(got, want) { - t.Fatalf("ForgeCompilerArgs(custom) = %#v, want %#v", got, want) - } -} - -func TestForgeCompilerArgsExplicitDoesNotApplyDefaults(t *testing.T) { - got := ForgeCompilerArgsExplicit(&model.CompilerConfig{EVMVersion: "paris"}) - want := []string{"--evm-version", "paris"} - if !reflect.DeepEqual(got, want) { - t.Fatalf("ForgeCompilerArgsExplicit(custom) = %#v, want %#v", got, want) - } -} diff --git a/frontend/src/api/schemas.ts b/frontend/src/api/schemas.ts index 628c98e..af7fa96 100644 --- a/frontend/src/api/schemas.ts +++ b/frontend/src/api/schemas.ts @@ -35,19 +35,6 @@ export const stateOverrideSchema = z.object({ source: z.string() }); -export const compilerConfigSchema = z.object({ - use: z.string().optional(), - offline: z.boolean().optional(), - noAutoDetect: z.boolean().optional(), - viaIR: z.boolean().optional(), - useLiteralContent: z.boolean().optional(), - noMetadata: z.boolean().optional(), - evmVersion: z.string().optional(), - optimize: z.boolean().optional(), - optimizerRuns: z.number().int().min(0).max(4294967295).optional(), - revertStrings: z.enum(["default", "strip", "debug", "verboseDebug"]).optional() -}); - export const chainConfigSchema = z.object({ chains: z.array(z.string()).default([]), explorerUrls: z.record(z.string(), z.string()).default({}) @@ -84,7 +71,6 @@ export const simulateRequestSchema = z.object({ erc20ApprovalOverrides: z.array(erc20ApprovalOverrideSchema).optional(), erc721ApprovalOverrides: z.array(erc721ApprovalOverrideSchema).optional(), stateOverride: stateOverrideSchema.optional(), - compiler: compilerConfigSchema.optional(), decodeInternal: z.boolean().default(false), sender: addressSchema, target: addressSchema, @@ -166,7 +152,6 @@ export type ERC20BalanceOverride = z.infer; export type ERC20ApprovalOverride = z.infer; export type ERC721ApprovalOverride = z.infer; export type StateOverride = z.infer; -export type CompilerConfig = z.infer; export type ChainConfig = z.infer; export type ProjectsResponse = z.infer; export type ProjectSourceFileRequest = z.infer; diff --git a/frontend/src/api/types.ts b/frontend/src/api/types.ts index f0ff695..964993d 100644 --- a/frontend/src/api/types.ts +++ b/frontend/src/api/types.ts @@ -1,7 +1,6 @@ export type { BalanceAnalysis, ChainConfig, - CompilerConfig, ERC20ApprovalOverride, ERC20BalanceOverride, ERC20Transfer, diff --git a/frontend/src/app/form.ts b/frontend/src/app/form.ts index d8cf6f5..5f2ab8e 100644 --- a/frontend/src/app/form.ts +++ b/frontend/src/app/form.ts @@ -1,7 +1,6 @@ import { simulateRequestSchema, txRequestSchema } from "../api/schemas"; import { isAddress } from "../lib/labels"; import type { - CompilerConfig, ERC20ApprovalOverride, ERC20BalanceOverride, ERC721ApprovalOverride, @@ -38,14 +37,6 @@ export type FormState = { erc721ApprovalOverrides: ERC721ApprovalOverride[]; stateContractName: string; stateSource: string; - compilerUse: string; - optimizerRuns: string; - evmVersion: string; - revertStrings: string; - viaIR: boolean; - optimize: boolean; - offline: boolean; - noMetadata: boolean; decodeInternal: boolean; quick: boolean; }; @@ -70,14 +61,6 @@ export const defaults: FormState = { erc721ApprovalOverrides: [], stateContractName: "", stateSource: "", - compilerUse: "", - optimizerRuns: "", - evmVersion: "", - revertStrings: "", - viaIR: true, - optimize: true, - offline: false, - noMetadata: false, decodeInternal: false, quick: false }; @@ -92,7 +75,6 @@ export function formFromRecord(record: SimulationRecord, apiUrl: string): FormSt } export function formFromSimulationRequest(request: SimulateRequest, apiUrl: string): FormState { - const compiler = request.compiler ?? {}; const stateSource = request.stateOverride?.source ?? ""; const stateContractName = request.stateOverride?.contractName ?? ""; return { @@ -113,14 +95,6 @@ export function formFromSimulationRequest(request: SimulateRequest, apiUrl: stri erc721ApprovalOverrides: request.erc721ApprovalOverrides ?? [], stateContractName, stateSource, - compilerUse: compiler.use ?? "", - optimizerRuns: compiler.optimizerRuns === undefined ? "" : String(compiler.optimizerRuns), - evmVersion: compiler.evmVersion ?? "", - revertStrings: compiler.revertStrings ?? "", - viaIR: compiler.viaIR ?? defaults.viaIR, - optimize: compiler.optimize ?? defaults.optimize, - offline: compiler.offline ?? defaults.offline, - noMetadata: compiler.noMetadata ?? defaults.noMetadata, decodeInternal: request.decodeInternal ?? defaults.decodeInternal, quick: defaults.quick }; @@ -156,27 +130,6 @@ export function buildSimulationRequest(form: FormState): SimulateRequest { throw new Error("blockNumber is required unless latest block is enabled"); } - const compiler: CompilerConfig = { - viaIR: form.viaIR, - optimize: form.optimize - }; - optionalString(compiler, "use", form.compilerUse); - optionalString(compiler, "evmVersion", form.evmVersion); - optionalString(compiler, "revertStrings", form.revertStrings); - if (form.offline) { - compiler.offline = true; - } - if (form.noMetadata) { - compiler.noMetadata = true; - } - if (form.optimizerRuns.trim()) { - const runs = Number(form.optimizerRuns); - if (!Number.isInteger(runs) || runs < 0) { - throw new Error("optimizerRuns must be a non-negative integer"); - } - compiler.optimizerRuns = runs; - } - const request: SimulateRequest = { chain: form.chain, blockNumber: form.useLatestBlock ? "" : form.blockNumber.trim(), @@ -187,8 +140,7 @@ export function buildSimulationRequest(form: FormState): SimulateRequest { erc20BalanceOverrides: compactRows(form.erc20BalanceOverrides, ["token", "account", "balance"], "ERC20 balance overrides"), erc20ApprovalOverrides: compactRows(form.erc20ApprovalOverrides, ["token", "owner", "spender", "amount"], "ERC20 approval overrides"), erc721ApprovalOverrides: compactRows(form.erc721ApprovalOverrides, ["token", "owner", "spender", "tokenId"], "ERC721 approval overrides"), - decodeInternal: form.decodeInternal, - compiler + decodeInternal: form.decodeInternal }; optionalString(request, "projectPath", form.projectPath); diff --git a/frontend/src/features/request/RequestForm.tsx b/frontend/src/features/request/RequestForm.tsx index 6de4e2b..3258407 100644 --- a/frontend/src/features/request/RequestForm.tsx +++ b/frontend/src/features/request/RequestForm.tsx @@ -499,50 +499,7 @@ function RunOptionsTab(props: { form: FormState; isTxRequest: boolean; onUpdate:
onUpdate("decodeInternal", value)} /> {isTxRequest && onUpdate("quick", value)} />} - {!isTxRequest && ( - <> - onUpdate("viaIR", value)} /> - onUpdate("optimize", value)} /> - onUpdate("offline", value)} /> - onUpdate("noMetadata", value)} /> - - )}
- {!isTxRequest && ( - <> -
- - -
-
- - -
- - )} ); } diff --git a/frontend/tests/request-lookup.spec.ts b/frontend/tests/request-lookup.spec.ts index bc292e7..732a432 100644 --- a/frontend/tests/request-lookup.spec.ts +++ b/frontend/tests/request-lookup.spec.ts @@ -15,13 +15,6 @@ test("loads a saved request by request id", async ({ page }) => { contractName: "SavedOverride", source: "pragma solidity ^0.8.0; contract SavedOverride {}" }, - compiler: { - viaIR: false, - optimize: true, - optimizerRuns: 300, - evmVersion: "cancun", - revertStrings: "debug" - }, decodeInternal: true, sender: spender, target: token, @@ -53,10 +46,8 @@ test("loads a saved request by request id", async ({ page }) => { await expect(page.getByLabel("Override Contract Name")).toHaveValue("SavedOverride"); await expect(page.getByLabel("Override Contract Source")).toHaveValue("pragma solidity ^0.8.0; contract SavedOverride {}"); await page.getByRole("button", { name: "Run Options" }).click(); - await expect(page.getByLabel("Optimizer Runs")).toHaveValue("300"); - await expect(page.getByLabel("EVM Version")).toHaveValue("cancun"); - await expect(page.getByLabel("Revert Strings")).toHaveValue("debug"); await expect(page.getByLabel("decode internal")).toBeChecked(); + await expect(page.getByLabel("Solc")).toHaveCount(0); }); test("editing the request id clears a stuck lookup", async ({ page }) => { diff --git a/frontend/tests/simulation-ui.spec.ts b/frontend/tests/simulation-ui.spec.ts index b1bf79b..24993ef 100644 --- a/frontend/tests/simulation-ui.spec.ts +++ b/frontend/tests/simulation-ui.spec.ts @@ -178,6 +178,7 @@ test("adds source to the default project outside the simulation request", async const request = route.request().postDataJSON() as { projectPath?: string; projectSourceFiles?: unknown; + compiler?: unknown; blockNumber?: string; sender?: string; target?: string; @@ -185,6 +186,7 @@ test("adds source to the default project outside the simulation request", async }; expect(request.projectPath).toBe(defaultProjectPath); expect(request.projectSourceFiles).toBeUndefined(); + expect(request.compiler).toBeUndefined(); expect(JSON.stringify(request)).not.toContain("contract Token"); await route.fulfill({ status: 200, @@ -246,12 +248,14 @@ test("exports and imports simulation input and output", async ({ page }, testInf target?: string; data?: string; decodeInternal?: boolean; + compiler?: unknown; }; expect(request.blockNumber).toBe("23000000"); expect(request.sender).toBe(spender); expect(request.target).toBe(token); expect(request.data).toBe("0x23b872dd"); expect(request.decodeInternal).toBe(false); + expect(request.compiler).toBeUndefined(); await route.fulfill({ status: 200, contentType: "application/json", @@ -479,7 +483,7 @@ test("uses configured explorer links and renders only the last main call subtree await addLabel(page, recipient, "WETHRecipient"); await addLabel(page, searchOnlyAccount, "SearchOnlyAlias"); await page.getByRole("button", { name: "Run Options" }).click(); - await expect(page.getByLabel("Solc")).toBeVisible(); + await expect(page.getByLabel("decode internal")).toBeVisible(); await page.reload(); await expect(page.getByText("online")).toBeVisible(); @@ -492,7 +496,7 @@ test("uses configured explorer links and renders only the last main call subtree await expect(page.getByLabel("Target")).toHaveValue(token); await expect(page.getByLabel("Calldata")).toHaveValue("0x23b872dd"); await page.getByRole("button", { name: "Run Options" }).click(); - await expect(page.getByLabel("Solc")).toBeVisible(); + await expect(page.getByLabel("decode internal")).toBeVisible(); await page.getByRole("button", { name: "Run Simulation" }).click(); await expect(page.getByText("success |")).toBeVisible();