Repository navigation
[#4923] Fix the revm fork Low findings of the delta audit - #100
Conversation
Registry: - withdrawFees is accepted while the cycle is STARTED or READY and reverts with the new IConfigFacet.CycleTransitionInProgress while a cycle transition is pending (FINISHED or SUSPENDED). - NatSpec: a user task's priority is always its task index; only registerSystemTask applies _priority, and 0 selects the default. - DiamondInit and LibCommon state that the gas-config precompile serves the published EVM gas parameters during genesis, and why DiamondInit does not depend on it. Genesis generator (supra-extension): - The configuration requires a positive cycle duration strictly below both task duration caps. - The embedded Solidity bytecode is compiled from the project's foundry.toml alone: FOUNDRY_*/DAPP_* variables other than the allowed and bytecode-neutral ones are removed with a warning, and the global ~/.foundry/foundry.toml is not read. The build re-runs only for the variables that reach the compiler, and watches remappings.txt only when it exists, so an unchanged tree no longer re-runs the build script. Operator scripts: - Each governance action has digest(), and submit_governance_action.sh resumes a pending transaction only when the named action's digest equals the stored content hash. - deploy_automation_registry.sh signs with a Foundry keystore account, has --help, reads .env as data (script/dotenv.sh) and resolves ETH_PASSWORD from the caller's directory. - The scripts run under bash 3.2 and do not need realpath (macOS). Tests: withdrawFees per cycle state, auxData total-length cap, system task event trimming, fee multiplier exponent bound, AppStorage slot, Solidity enum mirrors, GenesisTransaction fields, default fees, damaged-artifact recompilation, Foundry configuration isolation, and the operator scripts (run in CI against stub forge and cast). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
macOS check: operator scripts under
|
isaacdoidge
left a comment
There was a problem hiding this comment.
Reviewed at 05572e8e. The V3-2, V4-3, V5-1 and V10-3 changes match the fix sketches on Entropy-Foundation/smr-moonshot#4923, and each added guard test fails without its guard. Inline: three changes needed (load_dotenv names, Foundry prefix matching, the stand-in home directory) and four nits.
macOS /bin/bash 3.2 test-plan item: passes. On macOS 27.2.1 with GNU bash, version 3.2.57(1)-release (arm64-apple-darwin26):
${h,,}fails withbad substitution;- the
trreplacement prints0xabcd; TEST_BASH=/bin/bash /bin/bash ./test/shell/operator_scripts_test.shends with15 tests, 0 failed (scripts run with /bin/bash: 3.2.57(1)-release).
CI (nit): V10-4 is guarded by a grep for a few bash 4 constructs, and forge-tests runs the shell tests under ubuntu's bash 5 only. A macOS job running the suite with TEST_BASH=/bin/bash would cover bash 3.2 compatibility as a whole rather than the listed constructs.
Question on V3-2: withdrawFees is refused for the whole of FINISHED and SUSPENDED, not only while isTransitionInProgress() is true. While the node keeps automation paused (getRecordMaxTaskCount returning 0), the cycle can stay FINISHED and the owner cannot withdraw until it advances. Is that the intended behaviour?
| local file=$1 line name value | ||
| while IFS= read -r line || [ -n "${line}" ]; do | ||
| [[ "${line}" =~ ^[[:space:]]*(export[[:space:]]+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$ ]] || continue | ||
| name=${BASH_REMATCH[2]} | ||
| value=${BASH_REMATCH[3]} | ||
| if [ -n "${!name+set}" ]; then | ||
| echo "Using ${name} from the environment, not from ${file}" | ||
| continue | ||
| fi | ||
| if [[ "${value}" =~ ^\"(.*)\"$ || "${value}" =~ ^\'(.*)\'$ ]]; then | ||
| value=${BASH_REMATCH[1]} | ||
| fi | ||
| export "${name}=${value}" |
There was a problem hiding this comment.
V4-4: load_dotenv should export only the names the calling script documents, e.g. an allow-list passed as a second argument, and ignore (with a message) any other name in the file. Please add a shell test for a name outside the list.
There was a problem hiding this comment.
Done in 5c9d8e9. load_dotenv <file> <name>... exports only the listed names and ignores any other name with "Ignoring NAME in : not a variable this script reads". Each script passes the names it documents. GOV_TXN_INDEX/GOV_TXN_CONTENT_HASH are not on the list, so they come from the environment only. New shell tests: test_deploy_dotenv_ignores_names_the_script_does_not_read (checks that forge does not see a FOUNDRY_SENDER from .env), test_submit_dotenv_ignores_the_resume_variables and test_load_dotenv_requires_the_names_to_read. Each fails without the allow-list.
| fn ambient_foundry_vars<'a>( | ||
| names: impl IntoIterator<Item = &'a str>, | ||
| allowed_env: &[&str], | ||
| ) -> Vec<String> { | ||
| let mut ambient: Vec<String> = names | ||
| .into_iter() | ||
| .filter(|name| { | ||
| FOUNDRY_ENV_PREFIXES | ||
| .iter() | ||
| .any(|prefix| name.starts_with(prefix)) |
There was a problem hiding this comment.
V5-2: foundry-config reads the environment through figment's Env, which trims each name and matches the prefix ignoring ASCII case (UncasedStr); Profile::from_env does the same for FOUNDRY_PROFILE. The filter here should select the same set of names: trim, compare the prefix case-insensitively, apply the same comparison against allowed_env, and cover case variants of FOUNDRY_PROFILE. every_foundry_and_dapp_variable_is_ambient could then include lowercase and space-padded names.
There was a problem hiding this comment.
Done in 5c9d8e9. foundry_env_key trims and uppercases, and every comparison (prefix, allowed names, FOUNDRY_PROFILE) goes through it. Every variant of FOUNDRY_PROFILE is removed even when allowed, because Profile::from_env takes the first match and select_foundry_profile sets the exact name afterwards. Names that are not UTF-8 are matched in their lossy form, as figment reads them, and removed by their original bytes. Unit tests cover lowercase, space-padded and allowed-variant names. The integration test sets foundry_optimizer and " Foundry_Optimizer ", and it fails if matching is made case-sensitive again.
| let empty_home = std::env::temp_dir().join(format!( | ||
| "supra-foundry-config-home-{}", | ||
| std::process::id() | ||
| )); | ||
| std::fs::create_dir_all(&empty_home)?; |
There was a problem hiding this comment.
The stand-in home should be a directory this build creates itself and only this user can access: create_dir (not create_dir_all) with mode 0700 and an unpredictable name, or a directory under OUT_DIR when it is set. On Linux temp_dir() is the shared /tmp, and create_dir_all succeeds on a fixed name that already exists.
There was a problem hiding this comment.
Done in 5c9d8e9. create_private_dir: DirBuilder::create (not create_dir_all) with mode 0700 on Unix and a RandomState-seeded suffix. It tries a new name on AlreadyExists, so an existing directory is never used. The parent is OUT_DIR when set, the temp dir otherwise. private_directories_are_new_empty_and_owner_only checks that each call gets its own directory, that it is empty and that its mode is 0700.
| /// at an empty directory for the duration of the load and restored before this returns. | ||
| /// Compilation runs after the restore, so the compiler is found in the usual place. | ||
| /// | ||
| /// Changes `HOME` for the whole process while it runs; a build script is single-threaded. |
There was a problem hiding this comment.
Nit: on the retry path (discard_compiled_output → load_project_config), foundry-compilers' rayon pool has already started, so the process is not single-threaded. Suggest stating what holds: no other thread reads the environment while the configuration loads.
There was a problem hiding this comment.
Reworded in 5c9d8e9: no other thread may read the environment while the configuration loads. On the retry path the compiler's thread pool exists but is idle then: the first compilation has returned and the second has not started.
| } | ||
|
|
||
| # Runs the script $1 of the scratch project with the remaining arguments, under TEST_BASH, with | ||
| # the stubs first on PATH and a clean environment apart from the variables the caller exports. |
There was a problem hiding this comment.
Nit: run_script passes on the caller's whole environment, so "a clean environment apart from the variables the caller exports" does not describe what happens. Either clear it (env -i plus PATH/HOME) or reword the comment.
There was a problem hiding this comment.
Fixed in 5c9d8e9: the harness now unsets every variable the scripts read, from the environment or .env, before any test runs. The comment says the scripts inherit that environment plus what the test exports.
| case "${ETH_PASSWORD}" in | ||
| /*) ;; | ||
| *) ETH_PASSWORD="$(pwd)/${ETH_PASSWORD}" ;; |
There was a problem hiding this comment.
Nit: a relative ETH_PASSWORD read from .env resolves against the caller's directory, not the directory of the .env file. The PR says that is intended; the --help text should then say what a relative path is relative to.
There was a problem hiding this comment.
Done in 5c9d8e9: --help now says a relative ETH_PASSWORD is relative to the directory the script is run from, also when set in .env, and that a leading ~/ is expanded.
| let link = home.join(&svm); | ||
| std::fs::create_dir_all(link.parent().expect("a relative path has a parent")) | ||
| .expect("the link's directory is creatable"); | ||
| std::os::unix::fs::symlink(&real, &link).expect("the solc installs are linkable"); |
There was a problem hiding this comment.
Nit: std::os::unix::fs::symlink is not under #[cfg(unix)], so --all-features tests do not compile on Windows. The test relies on HOME, which is Unix-only too, so gating the whole test file with #![cfg(unix)] fits. CI is ubuntu-only, so nothing fails today.
There was a problem hiding this comment.
Done in 5c9d8e9: #![cfg(unix)] on the whole file, with the reason in its header.
Yes it is the intended behaviour. If you see any use-case that the current logic will affect UX please let me know. |
… as foundry-config does Review of #100: - load_dotenv exports only the names the calling script documents and ignores any other name in .env with a message. GOV_TXN_INDEX and GOV_TXN_CONTENT_HASH are read from the environment only. - The Foundry environment isolation matches names as foundry-config does (trimmed, prefix compared ignoring ASCII case), against allowed names too, and removes every variant of FOUNDRY_PROFILE before the build sets it. - The stand-in home directory used while loading the Foundry configuration is a new directory with an unpredictable name, mode 0700, under OUT_DIR when set. - Docs: the threading condition of load_project_config, what a relative ETH_PASSWORD is relative to, the operator-script test harness's environment, and the .env allow-list in the README. - foundry_config_isolation builds on Unix only. - CI runs the operator-script tests on macOS under /bin/bash 3.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review and the macOS run. Everything is addressed in 5c9d8e9 (replies on each thread). On the CI nit: a new job, |
GovActions.t.sol keeps #100's digest tests and this branch's test_acceptsTheLargestLimitBlockMetaAccepts, which replaced test_acceptsALimitEqualToTheCallableShare. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Fixes the Low findings of the revm fork delta audit roll-up, Entropy-Foundation/smr-moonshot#4923, except three that other changes cover:
Registry (Solidity)
withdrawFeesis accepted while the cycle is STARTED or READY. While a cycle transition is pending (FINISHED or SUSPENDED), it reverts with the newIConfigFacet.CycleTransitionInProgress. Because the ABI changed, theConfigFacetgolden hash is updated.registerSystemTaskapplies_priority, and 0 there selects the default.DiamondInitandLibCommonnow state that the gas-config precompile serves the published EVM gas parameters during genesis. They also say whyDiamondInitdoes not depend on it: the Forge fixtures and the ee-tests run without the precompile.Genesis generator (
supra-extension)cycle_duration_secs > 0, strictly below both task duration caps. This mirrorsLibCommon.validateConfigParameters.foundry.tomlalone.FOUNDRY_*/DAPP_*variable is removed, with a cargo warning, except two kinds:FOUNDRY_OFFLINE, which cannot change the bytecode.~/.foundry/foundry.tomlis not read:HOMEpoints to an empty directory while the configuration loads.remappings.txtis watched only when it exists. A watched path that does not exist made the build script rerun on every build, rebuilding every dependent crate each time.Operator scripts
digest()function.submit_governance_action.shresumes a pending transaction only when the named action's digest equals bothGOV_TXN_CONTENT_HASHand the hash the wallet stores.deploy_automation_registry.sh(local testing only) changes:--help;.envas data, never as shell code (script/dotenv.sh);ETH_PASSWORD, including a leading~/, from the caller's directory.${var,,}orrealpath, so they run with macOS's/bin/bash3.2, andrealpathis not needed on releases before macOS 13.submit_governance_action.shis now executable, as the README's./submit_governance_action.shassumes.Tests (V1 gaps, V6-3, V13-1, #41, #42, #47, #51, #74)
withdrawFeesin each cycle state, the auxData total-length cap, event trimming incancelSystemTasks/stopSystemTasks, no squaring after the last exponent bit, and the AppStorage slot.LibCommon.solenums, by name, order anduint8value;GenesisTransactioncarries no value field;foundry.toml).test/shell/operator_scripts_test.shruns the operator scripts against stubforgeandcast. CI runs it in theforge-testsjob.Motivation
These are the findings of Entropy-Foundation/smr-moonshot#4923 that were still open on
feature/evm_automation(rc28), each with the decision recorded on the issue. The added tests fill the V1 test gaps: at rc28, each guard below could be removed without any test failing.Test plan
cargo fmt --all --checkRUSTFLAGS=-Dwarnings cargo clippy --release --workspace --all-targets --all-featurescargo nextest run --release --workspace --all-features: 707 passed, 1 skippedforge test: 710 passedcheck_event_indexing.sh,check_facet_selectors.sh, andforge build --sizesunder the default and production profiles./test/shell/operator_scripts_test.sh: 15 passed under bash 5withdrawFeesstate.ETH_PASSWORDresolution and therealpathcheck.FOUNDRY_OPTIMIZER=falseno longer reruns the build script./bin/bash3.2 run (requested from a macOS reviewer):Notes
GovActions.s.sol, theconfigs.rstests and theConfigFacetNatSpec. Whichever merges second needs a merge.FOUNDRY_*/DAPP_*variable in the build environment now produces a warning and is ignored, instead of failing the build.remappings.txtlater needscargo clean -p revm-supra-extensionto be picked up.🤖 Generated with Claude Code