Skip to content

add EVM targets to grammar#1823

Merged
OmarTawfik merged 6 commits into
mainfrom
OmarTawfik/stacks/versions/4/add-evm-hardforks
Jun 9, 2026
Merged

add EVM targets to grammar#1823
OmarTawfik merged 6 commits into
mainfrom
OmarTawfik/stacks/versions/4/add-evm-hardforks

Conversation

@OmarTawfik

@OmarTawfik OmarTawfik commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

This PR adds EvmTarget as a data type to our grammar, and adds a new evm_enabled field to all built-ins, along with a generated strongly-typed enum, and a EvmTargetSpecifier helper, matching what we have for LanguageVersion.

A built-in's availability is gated on two axes:

  • Solidity frontend (enabled = {version}) - the version at which the compiler started accepting the name. Example: abi.encodeCall is rejected by solc before 0.8.11 regardless of the EVM target.
  • EVM target (evm_enabled = {target}) - the target at which the opcode/feature a built-in lowers to became available. Example: blockhash's sibling block.blobbasefee lowers to BLOBBASEFEE, which only exists from Cancun, regardless of the frontend version.

The two are independent: a built-in may carry one attribute, the other, or both, and when both are present both must hold. Empirically, blobhash requires solc >=0.8.24 (frontend) and Cancun (opcode): solc-0.8.23 @ cancun and solc-0.8.24 @ shanghai both reject it.

Note: evm_enabled is metadata-only for now. A later PR will add the relevant diagnostics, and update the binder to use the new metadata.

@changeset-bot

changeset-bot Bot commented Jun 2, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 53dea41

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@OmarTawfik OmarTawfik marked this pull request as ready for review June 2, 2026 16:10
@OmarTawfik OmarTawfik requested review from a team as code owners June 2, 2026 16:10
@OmarTawfik OmarTawfik marked this pull request as draft June 2, 2026 16:23
@OmarTawfik OmarTawfik marked this pull request as ready for review June 2, 2026 20:05
@OmarTawfik OmarTawfik changed the title add EVM hardforks to grammar add EVM targets to grammar Jun 2, 2026

@ggiraldez ggiraldez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Left a couple of questions (just a one in two places actually), but otherwise looks great!

Comment on lines +33 to +37
Self::From { from } => (*from as u32) <= (other as u32),
Self::Till { till } => (other as u32) < (*till as u32),
Self::Range { from, till } => {
(*from as u32) <= (other as u32) && (other as u32) < (*till as u32)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Q: why are you casting to u32 here? Since the enum derives Ord and PartialOrd the comparisons could be done without casting. Is there any advantage to it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was because the built-in derive doesn't generate const implementations. This is probably an overkill, so I simplified/removed the const.

Comment on lines +40 to +44
Self::From { from } => (*from as u32) <= (other as u32),
Self::Till { till } => (other as u32) < (*till as u32),
Self::Range { from, till } => {
(*from as u32) <= (other as u32) && (other as u32) < (*till as u32)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same question as before: why cast the values for comparison?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was because the built-in derive doesn't generate const implementations. This is probably an overkill, so I simplified/removed the const.

@OmarTawfik OmarTawfik force-pushed the OmarTawfik/stacks/versions/3/fix-function-builtin branch from 808a8c3 to 425d32d Compare June 5, 2026 19:14
@OmarTawfik OmarTawfik force-pushed the OmarTawfik/stacks/versions/4/add-evm-hardforks branch from 5600951 to c692190 Compare June 5, 2026 19:14
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

BranchOmarTawfik/stacks/versions/4/add-evm-hardforks
Testbedci

⚠️ WARNING: Truncated view!

The full continuous benchmarking report exceeds the maximum length allowed on this platform.

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

🐰 View full continuous benchmarking report in Bencher

Base automatically changed from OmarTawfik/stacks/versions/3/fix-function-builtin to main June 5, 2026 20:06
@OmarTawfik OmarTawfik force-pushed the OmarTawfik/stacks/versions/4/add-evm-hardforks branch from c692190 to 19e2b35 Compare June 6, 2026 11:54
@OmarTawfik OmarTawfik force-pushed the OmarTawfik/stacks/versions/4/add-evm-hardforks branch from 19e2b35 to 53dea41 Compare June 9, 2026 03:02
@OmarTawfik OmarTawfik enabled auto-merge June 9, 2026 03:02
@OmarTawfik OmarTawfik added this pull request to the merge queue Jun 9, 2026
Merged via the queue into main with commit b75b90b Jun 9, 2026
17 checks passed
@OmarTawfik OmarTawfik deleted the OmarTawfik/stacks/versions/4/add-evm-hardforks branch June 9, 2026 03:36
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.

2 participants