resolc: Detect undeployable contracts at link time - #599
Open
dimartiro wants to merge 4 commits into
Open
Conversation
4 tasks
xermicus
reviewed
Aug 25, 2026
| !debug_config.emit_debug_info, | ||
| ) { | ||
| Ok((memory_buffer_linked, ObjectFormat::PVM)) => { | ||
| self.messages.extend(check_deployment_limits( |
Member
There was a problem hiding this comment.
Build::write_to_standard_json considers errors, so does this doesn't work in std json mode? Would be nice to have a test for that too.
Author
There was a problem hiding this comment.
Good catch — it didn't. write_to_standard_json only forwarded errors from results and dropped messages, which is where the deployment-limit diagnostics (and other link-time issues) live.
They now land in the standard JSON errors array. Added coverage for --standard-json: the error, --ignore-memory-limit as a warning, and a larger --memory-limit.
Addressed in 98e6232.
write_to_standard_json only forwarded errors from results, so link-time diagnostics in messages never reached Hardhat and other stdjson users.
dimartiro
force-pushed
the
feat/96-blob-size-limit
branch
from
August 26, 2026 14:37
98e6232 to
e491463
Compare
xermicus
requested changes
Sep 8, 2026
|
|
||
| impl PalletLimits { | ||
| /// The limits of the Asset Hub runtime. | ||
| pub const ASSET_HUB: Self = Self { |
Member
There was a problem hiding this comment.
Instead of duplicating code here, we should re-use this from pallet-revive directly. It's already in the dependency tree.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #96
A contract whose linked blob exceeds the target runtime's limits compiles fine and is then rejected by
pallet_reviveon deployment. This reproduces the pallet's checks at link time so the problem surfaces where it can still be acted on.What it checks
pallet_revive::limits::code::enforcerejects a blob on four grounds the compiler can evaluate: the blob length (BLOB_BYTES), the longest basic block (BASIC_BLOCK_SIZE), and the purgeable and baseline interpreter memory (PURGABLE_MEMORY_LIMIT,BASELINE_MEMORY_LIMIT). All four are now checked, and each reports the measured value against the limit it broke.The memory figures are not approximated. The pallet derives them from
ProgramBlob::estimate_interpreter_memory_usage, andrevivealready depends onpolkavm-common, socrates/linker/src/limits.rscalls the same API with the same arguments and reaches the same verdict rather than a conservative guess.Interface
--memory-limit <BYTES>: the target runtime's baseline interpreter memory budget, defaulting to Asset Hub's. The compiler cannot know which runtime a blob is destined for, and the same chain at a different runtime version can carry a different budget.--ignore-memory-limit: report violations as warnings and emit the contract anyway.Exceeding the budget is an error by default, on the grounds that a contract which cannot be deployed is not a useful build artifact.
Why this matters in practice
The baseline budget is where it bites, and it is easy to cross without touching a line of Solidity, because the static heap and stack buffers are part of it. Compiling
Baseline.solunchanged:--heap-sizeBefore this change the last row compiled successfully and produced a contract that could never be deployed. It now fails with the numbers and a pointer at the knob to turn: