Repository navigation
Build simulator from .yul source - #6799
Merged
james-toussaint merged 15 commits intoOct 15, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: 4a0cc67 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Contributor
view gas comparisonChanges to gas costs
|
Replace the build task override and compile-yul task with a solidity.build hook
that compiles .yul files found in the sources directories and emits regular
Hardhat artifacts, so tests can use artifacts.readArtifact('CallSimulator').
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
@james-toussaint I pushed 05f1b90, which integrates the Yul plugin more directly into the Hardhat build:
The Foundry |
2 of 3 tasks
Hardhat's Solidity test runner requires every artifact in artifacts/ to have a buildInfoId it can parse the solc version from. No build info file is written, so EDR never sees a Yul build info. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The upgradeable build also compiles lib/openzeppelin-contracts/contracts/utils/CallSimulator.yul, making the bare name ambiguous. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 task
The Yul source was rewritten in the previous commit but the initcode embedded in getSimulator() still matched the old version, so the deployed simulator landed at a different CREATE2 address than the compiled artifact predicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Amxx
reviewed
Oct 12, 2026
Amxx
reviewed
Oct 12, 2026
Short calldata is now documented as undefined behavior: the length computation
underflows and calldatacopy runs out of gas. Also inline datasize("runtime") in
the constructor (no bytecode change) and update the embedded initcode.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Amxx
approved these changes
Oct 14, 2026
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.
The call simulator used by
SimulateCallwas hand-written EVM bytecode, documented with an opcode table and pasted into bothgetSimulator()and the tests. This PR replaces it with a Yul source,contracts/utils/SimulateCall.yul, that is compiled as part of the regular build, and checks that the embedded bytecode matches it.Changes
contracts/utils/SimulateCall.yul: new Yul source for the simulator (SimulationRelayerobject). It forwards the call described bytarget[0x00:0x14] | value[0x14:0x34] | data[0x34:]and inverts the outcome: it reverts on success (undoing state changes) and returns on failure, forwarding the return data in both cases.contracts/utils/SimulateCall.sol:getSimulator()embeds the initcode compiled from the Yul source. The opcode table is replaced by a pointer to the source.hardhat/hardhat-yul: new Hardhat plugin. Asolidity.buildhook compiles every.yulfile in the sources directories with the configured solc and emits regular Hardhat artifacts (e.g.contracts/utils/SimulateCall.yul:SimulationRelayer).getSimulator()equals the artifact'sdeployedBytecode, so the embedded bytecode can't drift from the source.slitherFoundry profile that skips*.yul, used by the Slither CI job.Behavior change
The simulator bytecode changes, so its CREATE2 address changes (changeset included). The new code is smaller: 47 bytes of initcode instead of 58, and 37 bytes of runtime instead of 49.
The explicit calldata length check is removed. Calldata shorter than 0x34 bytes is now undefined behavior, documented in the Yul source: the length computation underflows and
calldatacopyruns out of gas.SimulateCallalways sends well-formed calldata, so this only affects direct calls to the simulator.