Skip to content

feat(solidity): add a 0.9.0-pre.1 target and reject virtual modifiers - #53

Open
panditdhamdhere wants to merge 2 commits into
okcontract:mainfrom
panditdhamdhere:feat/solc-0.9-virtual-modifiers
Open

panditdhamdhere wants to merge 2 commits into
okcontract:mainfrom
panditdhamdhere:feat/solc-0.9-virtual-modifiers

Conversation

@panditdhamdhere

Copy link
Copy Markdown

Summary

  • Add a selectable Solidity 0.9.0-pre.1 target. The default remains 0.8.39.
  • On that target, reject virtual and override modifiers and modifiers without a body, matching solc 0.9.0-pre.1.
  • Solidity 0.8.36 through 0.8.39 still warn that virtual modifiers are scheduled for removal.

Test plan

  • zig build test-standard-json -Doptimize=Debug
  • zig test src/common/solc_version.zig
  • Full unit suite and lint

Select the pre-release without changing the 0.8.39 default, and match solc by rejecting virtual modifiers, override modifiers, and modifiers without a body.
@hbbio

hbbio commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR!

Can you please confirm and fix the following issue?

[P2] Encode the prerelease compiler identity as CBOR text

Location: src/common/solc_version.zig:56–57

The new target returns { 0, 9, 0 } from compactBytes(), and the existing CBOR metadata writer unconditionally serializes that as a byte string. Official solc 0.9.0-pre.1 instead writes the complete prerelease version as a text string.

Consequently, compilations using the new target with CBOR enabled produce different bytecode and lose the prerelease identity in the embedded metadata. This also happens with metadata.bytecodeHash = "none".

I reproduced this using the built PR CLI and the official compiler with:

// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.36;
contract C {}

With viaIR: true, optimization enabled, and metadata.bytecodeHash: "none", both compilers emit the same executable prefix, 5f80fdfe, followed by different metadata:

Output CBOR solc value CBOR payload size
PR head, targeting 0.9.0-pre.1 Byte string 00 09 00 10 bytes
Official solc 0.9.0-pre.1 Text "0.9.0-pre.1+commit.91c99213" 35 bytes

Suggested fix: Make createCBORMetadataAlloc() use isPrerelease() to select text encoding of metadataVersion() for prerelease targets. Keep compact byte encoding for stable releases, and add a regression test that compares the emitted trailer against the reference compiler. The added integration tests request ABI output, so they don’t exercise this path.

Match solc 0.9.0-pre.1 by writing the compiler version as text in bytecode metadata. Stable releases keep the 3-byte version.
@panditdhamdhere

Copy link
Copy Markdown
Author

Fixed in 124d492.

createCBORMetadataAlloc() now uses isPrerelease(). For 0.9.0-pre.1 the solc entry is CBOR text of metadataVersion() (0.9.0-pre.1+commit.91c99213), a 35-byte payload. Stable releases still write compactBytes() as a 3-byte string.

The version-isolation test compiles the same empty contract with viaIR and metadata.bytecodeHash: "none", and checks the deployed-bytecode trailer: the text trailer for the prerelease, and a164736f6c6343{version}000a for 0.8.36 through 0.8.39. A unit test also checks that the prerelease encoding is 37 bytes and does not contain 00 09 00.

zig build test-standard-json -Doptimize=Debug passed.

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